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

Unified Diff: sdk/lib/_internal/compiler/implementation/dart_backend/placeholder_collector.dart

Issue 11414113: [dart2dart] implement factory redirects (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Created 8 years, 1 month 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/co19/co19-dart2dart.status » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: sdk/lib/_internal/compiler/implementation/dart_backend/placeholder_collector.dart
diff --git a/sdk/lib/_internal/compiler/implementation/dart_backend/placeholder_collector.dart b/sdk/lib/_internal/compiler/implementation/dart_backend/placeholder_collector.dart
index b31e471a9cc33d90d851f047501a0bce8f156906..57a613ad62baea7829bdf4814adebb0b4e7924ab 100644
--- a/sdk/lib/_internal/compiler/implementation/dart_backend/placeholder_collector.dart
+++ b/sdk/lib/_internal/compiler/implementation/dart_backend/placeholder_collector.dart
@@ -30,6 +30,7 @@ class ConstructorPlaceholder {
final bool isRedirectingCall;
ConstructorPlaceholder(this.node, this.type)
: this.isRedirectingCall = false;
+ // Note: factory redirection is not redirecting call!
ConstructorPlaceholder.redirectingCall(this.node)
: this.type = null, this.isRedirectingCall = true;
}
@@ -175,6 +176,15 @@ class PlaceholderCollector extends Visitor {
if (element.isGenerativeConstructor() || element.isFactoryConstructor()) {
DartType type = element.getEnclosingClass().type.asRaw();
makeConstructorPlaceholder(node.name, element, type);
+ Return bodyAsReturn = node.body.asReturn();
+ if (bodyAsReturn != null && bodyAsReturn.isRedirectingFactoryBody) {
+ // Factory redirection.
+ FunctionElement redirectTarget = element.defaultImplementation;
+ assert(redirectTarget != null && redirectTarget != element);
+ type = redirectTarget.getEnclosingClass().type.asRaw();
+ makeConstructorPlaceholder(
+ bodyAsReturn.expression, redirectTarget, type);
+ }
} else if (Elements.isStaticOrTopLevel(element)) {
// Note: this code should only rename private identifiers for class'
// fields/getters/setters/methods. Top-level identifiers are renamed
« no previous file with comments | « no previous file | tests/co19/co19-dart2dart.status » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698