Chromium Code Reviews| Index: lib/compiler/implementation/resolver.dart |
| diff --git a/lib/compiler/implementation/resolver.dart b/lib/compiler/implementation/resolver.dart |
| index 38909e31f51a14e1d32e72ff97a4216f3cc95f6b..60f00948603529dbfb47de28653528f07d7dbd4f 100644 |
| --- a/lib/compiler/implementation/resolver.dart |
| +++ b/lib/compiler/implementation/resolver.dart |
| @@ -167,24 +167,25 @@ class ResolverTask extends CompilerTask { |
| // [intrface] is an interface, let's say "MyInterface". |
| // [defaultClass] is a class, let's say "MyClass". |
| - // First look up the constructor named "MyInterface.name". |
| - constructor.defaultImplementation = |
| - defaultClass.lookupConstructor(constructor.name); |
| + // If the default class implements the interface then we must use the |
| + // default class' name. Otherwise we look for a factory with the name |
| + // of the interface. |
| + SourceString name; |
| + if (defaultClass.implementsInterface(intrface)) { |
| + name = new SourceString(constructor.name.slowToString().replaceFirst( |
|
ahe
2012/04/10 14:30:38
Please add "TODO(ahe): Don't use string replacemen
floitsch
2012/04/11 11:40:56
Done.
|
| + intrface.name.slowToString(), |
| + defaultClass.name.slowToString())); |
| + } else { |
| + name = constructor.name; |
| + } |
| + constructor.defaultImplementation = defaultClass.lookupConstructor(name); |
| - // If that fails, try looking up "MyClass.name". |
| if (constructor.defaultImplementation === null) { |
| - SourceString name = |
| - new SourceString(constructor.name.slowToString().replaceFirst( |
| - intrface.name.slowToString(), |
| - defaultClass.name.slowToString())); |
| - constructor.defaultImplementation = defaultClass.lookupConstructor(name); |
| - |
| - if (constructor.defaultImplementation === null) { |
| - // We failed find a constrcutor named either |
| - // "MyInterface.name" or "MyClass.name". |
| - error(node, MessageKind.CANNOT_FIND_CONSTRUCTOR2, |
| - [constructor.name, name]); |
| - } |
| + // We failed to find a constructor named either |
| + // "MyInterface.name" or "MyClass.name". |
| + error(node, |
| + MessageKind.CANNOT_FIND_CONSTRUCTOR2, |
| + [name, defaultClass.name]); |
| } |
| } |