| Index: lib/compiler/implementation/resolver.dart
|
| diff --git a/lib/compiler/implementation/resolver.dart b/lib/compiler/implementation/resolver.dart
|
| index 38909e31f51a14e1d32e72ff97a4216f3cc95f6b..22ecb705f7bd311e4506fed0228f76b415633d79 100644
|
| --- a/lib/compiler/implementation/resolver.dart
|
| +++ b/lib/compiler/implementation/resolver.dart
|
| @@ -167,24 +167,26 @@ 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)) {
|
| + // TODO(ahe): Don't use string replacement here.
|
| + name = new SourceString(constructor.name.slowToString().replaceFirst(
|
| + 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]);
|
| }
|
| }
|
|
|
|
|