Fix handling of sends with wrong arity

Review URL: https://codereview.chromium.org//11412148

git-svn-id: https://dart.googlecode.com/svn/branches/bleeding_edge/dart@15507 260f80e4-7a28-3924-810f-c04153c831b5
This commit is contained in:
polux@google.com 2012-11-29 10:14:05 +00:00
parent 6390a1f110
commit cbd18d2762
3 changed files with 23 additions and 4 deletions

View file

@ -601,13 +601,11 @@ class ConcreteTypesInferrer {
ConcreteType result = new ConcreteType.empty();
Map<Element, ConcreteType> argumentMap =
associateArguments(function, argumentsTypes);
argumentMap.forEach((Element parameter, ConcreteType type) {
augmentParameterType(parameter, type);
});
// if the association failed, this send will never occur or will fail
if (argumentMap == null) {
return new ConcreteType.empty();
}
argumentMap.forEach(augmentParameterType);
ConcreteTypeCartesianProduct product =
new ConcreteTypeCartesianProduct(receiverType, argumentMap);
for (ConcreteTypesEnvironment environment in product) {

View file

@ -588,6 +588,25 @@ testFieldInitialization() {
result.checkFieldHasType('A', 'y', [result.int]);
}
testSendWithWrongArity() {
final String source = r"""
f(x) { }
class A { g(x) { } }
main () {
var x = f();
var y = f(1, 2);
var z = new A().g();
var w = new A().g(1, 2);
x; y; z; w;
}
""";
AnalysisResult result = analyze(source);
result.checkNodeHasType('x', []);
result.checkNodeHasType('y', []);
result.checkNodeHasType('z', []);
result.checkNodeHasType('w', []);
}
void main() {
testLiterals();
testRedefinition();
@ -614,4 +633,5 @@ void main() {
testCompoundOperators1();
testCompoundOperators2();
// testFieldInitialization(); // TODO(polux)
testSendWithWrongArity();
}

View file

@ -45,7 +45,8 @@ const String DEFAULT_HELPERLIB = r'''
abstract class JavaScriptIndexingBehavior {}
class JSInvocationMirror {}
S() {}
assertHelper(a){}''';
assertHelper(a){}
throwNoSuchMethod(obj, name, arguments, expectedArgumentNames) {}''';
const String DEFAULT_INTERCEPTORSLIB = r'''
class JSArray {