Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(35)

Unified Diff: pkg/compiler/lib/src/ssa/builder_kernel.dart

Issue 2896393003: Remove factory body in *.fromEnvironment, and implement this same behavior (Closed)
Patch Set: turn warning into a hint Created 3 years, 7 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « pkg/compiler/lib/src/ssa/builder.dart ('k') | pkg/compiler/lib/src/ssa/kernel_impact.dart » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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);
}
« no previous file with comments | « pkg/compiler/lib/src/ssa/builder.dart ('k') | pkg/compiler/lib/src/ssa/kernel_impact.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698