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

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..34914cb665527e8afada5c33a427227d0fcd1610 100644
--- a/lib/compiler/implementation/dart_backend/placeholder_collector.dart
+++ b/lib/compiler/implementation/dart_backend/placeholder_collector.dart
@@ -105,6 +105,14 @@ class PlaceholderCollector extends AbstractVisitor {
localPlaceholders = new Map<FunctionElement, Set<LocalPlaceholder>>(),
privateNodes = new Map<LibraryElement, Set<Identifier>>();
+ void renameConstructorName(Node nameNode, ClassElement element) {
Anton Muhin 2012/08/21 11:18:42 rename/name sounds a big ugly, maybe something lik
Roman 2012/08/21 11:23:40 Renamed to tryMakeConstructorNamePlaceholder
+ if (nameNode is Send) nameNode = nameNode.receiver;
+ if (nameNode.asIdentifier().token.slowToString()
+ == element.name.slowToString()) {
+ makeElementPlaceholder(nameNode, element);
+ }
+ }
+
void collectFunctionDeclarationPlaceholders(
FunctionElement element, FunctionExpression node) {
if (element.isGenerativeConstructor() || element.isFactoryConstructor()) {
@@ -119,14 +127,27 @@ class PlaceholderCollector extends AbstractVisitor {
// 0.dart: class C { C(); }
// 1.dart: interface C default p0.C { C(); }
// the second case is just a bug now.
- final enclosingClass = element.getEnclosingClass();
- Node nameNode = node.name;
- if (nameNode is Send) nameNode = nameNode.receiver;
- // For cases like class C implements I { I(); }
- if (nameNode.asIdentifier().token.slowToString()
- == enclosingClass.name.slowToString()) {
- makeTypePlaceholder(nameNode, enclosingClass.type);
+ renameConstructorName(node.name, element.getEnclosingClass());
+
+ // If we have interface constructor, make sure that we put placeholder
+ // for its default factory implementation.
+ // Example:
+ // interface I default C { I();}
+ // class C { factory I() {} }
+ // 2 cases:
+ // 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.
+ // OR I.named() inside C, rename first part.
+ if (element.defaultImplementation !== null
+ && element.defaultImplementation !== element) {
+ FunctionElement implementingFactory = element.defaultImplementation;
+ renameConstructorName(implementingFactory.cachedNode.name,
Anton Muhin 2012/08/21 11:18:42 maybe move .name into renameConsturctorName--it's
Roman 2012/08/21 11:23:40 Done.
+ element.getEnclosingClass());
}
+
// 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