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

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

Issue 10828390: dart2dart Fix factory for interfaces renames (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Created 8 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/compiler/dart2js/unparser_test.dart » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: lib/compiler/implementation/dart_backend/placeholder_collector.dart
diff --git a/lib/compiler/implementation/dart_backend/placeholder_collector.dart b/lib/compiler/implementation/dart_backend/placeholder_collector.dart
index e4813c71903645dea9d6e8e612ea50e4205624be..76b5f672e1fe85603712c18f446d1a40543bfed9 100644
--- a/lib/compiler/implementation/dart_backend/placeholder_collector.dart
+++ b/lib/compiler/implementation/dart_backend/placeholder_collector.dart
@@ -122,11 +122,38 @@ class PlaceholderCollector extends AbstractVisitor {
final enclosingClass = element.getEnclosingClass();
Node nameNode = node.name;
if (nameNode is Send) nameNode = nameNode.receiver;
- // For cases like class C implements I { I(); }
+ // Skip cases like class C implements I { I(); }
if (nameNode.asIdentifier().token.slowToString()
Anton Muhin 2012/08/21 09:06:36 as you're touching this code anyway, maybe make it
Roman 2012/08/21 09:18:41 Done.
== enclosingClass.name.slowToString()) {
makeTypePlaceholder(nameNode, enclosingClass.type);
}
+
+ // If we have interface constructor, make sure that we put placeholder
+ // for its default factory implementation.
+ // Example:
+ // interface I { I();}
+ // class C { I() {} }
+ if (element.defaultImplementation !== null
+ && element.defaultImplementation !== element) {
+ FunctionElement implementingFactory = element.defaultImplementation;
+ Node factoryName = implementingFactory.cachedNode.name;
+ if (factoryName is Identifier) {
+ // Plain interface name. Rename it unless it is the default
+ // constructor for enclosing class.
+ // Example:
+ // interface I { I(); }
+ // class C implements I { C(); } don't rename this case.
+ if (factoryName.token
+ != implementingFactory.getEnclosingClass().name) {
+ makeElementPlaceholder(factoryName, enclosingClass);
+ }
+ } else {
+ // I.named() inside C, rename first part.
+ assert(factoryName is Send);
+ makeElementPlaceholder(factoryName.asSend().receiver, enclosingClass);
Anton Muhin 2012/08/21 09:06:36 it looks like you don't check here if you should r
Roman 2012/08/21 09:18:41 I don't understand your comment., what should I re
+ }
+ }
+
// Process Ctor(this._field) correctly.
for (Node parameter in node.parameters) {
VariableDefinitions definitions = parameter.asVariableDefinitions();
« no previous file with comments | « no previous file | tests/compiler/dart2js/unparser_test.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698