Chromium Code Reviews| 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(); |