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

Unified Diff: sdk/lib/_internal/compiler/implementation/inferrer/simple_types_inferrer.dart

Issue 519693002: Properly handle forwarding factory constructors in type inference. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Created 6 years, 4 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 | « no previous file | tests/language/forwarding_factory_constructor_default_values_test.dart » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: sdk/lib/_internal/compiler/implementation/inferrer/simple_types_inferrer.dart
diff --git a/sdk/lib/_internal/compiler/implementation/inferrer/simple_types_inferrer.dart b/sdk/lib/_internal/compiler/implementation/inferrer/simple_types_inferrer.dart
index af97966c71e4d4fc0f784ae620b777ff1fe48c06..0008dd5dbf6f1521df87c8ec9be9f483fdf58bda 100644
--- a/sdk/lib/_internal/compiler/implementation/inferrer/simple_types_inferrer.dart
+++ b/sdk/lib/_internal/compiler/implementation/inferrer/simple_types_inferrer.dart
@@ -979,6 +979,15 @@ class SimpleTypeInferrerVisitor<T>
analyzeSuperConstructorCall(element, arguments);
}
}
+ // If we are looking at a new expression on a forwarding factory,
+ // we have to forward the call to the effective target of the
+ // factory.
+ if (element.isFactoryConstructor) {
+ ConstructorElement constructor = element;
+ if (constructor.isRedirectingFactory) {
+ element = constructor.effectiveTarget.implementation;
+ }
+ }
if (element.isForeign(compiler.backend)) {
return handleForeignSend(node);
}
@@ -1115,6 +1124,8 @@ class SimpleTypeInferrerVisitor<T>
Selector selector,
Element element,
ArgumentsTypes arguments) {
+ assert(!element.isFactoryConstructor ||
+ !(element as ConstructorElement).isRedirectingFactory);
// Erroneous elements may be unresolved, for example missing getters.
if (Elements.isUnresolved(element)) return types.dynamicType;
// TODO(herhut): should we follow redirecting constructors here? We would
« no previous file with comments | « no previous file | tests/language/forwarding_factory_constructor_default_values_test.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698