Index: pkg/compiler/lib/src/ssa/builder_kernel.dart |
diff --git a/pkg/compiler/lib/src/ssa/builder_kernel.dart b/pkg/compiler/lib/src/ssa/builder_kernel.dart |
index 0abf07d050c71267ed6a5b316af45d5bc68c828f..8c2561bdf8858f1824677ec1f076e45f98391970 100644 |
--- a/pkg/compiler/lib/src/ssa/builder_kernel.dart |
+++ b/pkg/compiler/lib/src/ssa/builder_kernel.dart |
@@ -1337,6 +1337,11 @@ class KernelSsaBuilder extends ir.Visitor with GraphBuilder { |
astAdapter.getReturnTypeOf(_commonElements.throwTypeError)); |
} |
+ void generateUnsupportedError(ir.Node node, String message) { |
+ generateError(node, _commonElements.throwUnsupportedError, message, |
+ astAdapter.getReturnTypeOf(_commonElements.throwUnsupportedError)); |
+ } |
+ |
@override |
void visitAssertStatement(ir.AssertStatement assertStatement) { |
if (!options.enableUserAssertions) return; |
@@ -2250,9 +2255,23 @@ class KernelSsaBuilder extends ir.Visitor with GraphBuilder { |
List<HInstruction> arguments = |
_visitArgumentsForStaticTarget(target.function, invocation.arguments); |
- // Factory constructors take type parameters; other static methods ignore |
- // them. |
if (function is ConstructorEntity && function.isFactoryConstructor) { |
+ if (function.isExternal && function.isFromEnvironmentConstructor) { |
+ if (invocation.isConst) { |
+ // Just like all const constructors (see visitConstructorInvocation). |
+ stack.add(graph.addConstant( |
+ astAdapter.getConstantFor(invocation), closedWorld)); |
+ } else { |
+ generateUnsupportedError( |
+ invocation, |
+ '${function.enclosingClass.name}.${function.name} ' |
+ 'can only be used as a const constructor'); |
+ } |
+ return; |
+ } |
+ |
+ // Factory constructors take type parameters; other static methods ignore |
+ // them. |
if (backend.rtiNeed.classNeedsRti(function.enclosingClass)) { |
_addTypeArguments(arguments, invocation.arguments); |
} |