Index: pkg/compiler/lib/src/js_backend/codegen/codegen.dart |
diff --git a/pkg/compiler/lib/src/js_backend/codegen/codegen.dart b/pkg/compiler/lib/src/js_backend/codegen/codegen.dart |
index d97abb45d0812d06cdc18b90137c920ec581bbec..07ec340b7e52201edc6060a94c32c7aa263522bb 100644 |
--- a/pkg/compiler/lib/src/js_backend/codegen/codegen.dart |
+++ b/pkg/compiler/lib/src/js_backend/codegen/codegen.dart |
@@ -180,6 +180,8 @@ class CodeGenerator extends tree_ir.Visitor<dynamic, js.Expression> { |
@override |
js.Expression visitInvokeConstructor(tree_ir.InvokeConstructor node) { |
+ checkStaticTargetIsValid(node, node.target); |
+ |
if (node.constant != null) return giveup(node); |
registry.registerInstantiatedClass(node.target.enclosingClass); |
return buildStaticInvoke(node.selector, |
@@ -203,8 +205,24 @@ class CodeGenerator extends tree_ir.Visitor<dynamic, js.Expression> { |
visitArguments(node.arguments)); |
} |
+ /// Checks that the target of the static call is not an [ErroneousElement]. |
+ /// |
+ /// This helper should be removed and the code to generate the CPS IR for |
+ /// the dart2js backend should construct a call to a helper that throw an |
+ /// appropriate error message instead of the static call. |
asgerf
2015/02/06 10:12:40
Agreed.
|
+ /// |
+ /// See [SsaBuilder.visitStaticSend] as an example how to do this. |
+ void checkStaticTargetIsValid(tree_ir.Node node, Element target) { |
+ if (target.isErroneous) { |
+ giveup(node, 'cannot generate error handling code' |
+ ' for call to unresolved target'); |
+ } |
+ } |
+ |
@override |
js.Expression visitInvokeStatic(tree_ir.InvokeStatic node) { |
+ checkStaticTargetIsValid(node, node.target); |
+ |
if (node.target is! FunctionElement) { |
giveup(node, 'static getters and setters are not supported.'); |
} |