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

Unified Diff: lib/compiler/implementation/resolver.dart

Issue 9980004: Look up the correct constructor for default classes. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: rebase Created 8 years, 8 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 | « lib/compiler/implementation/lib/mockimpl.dart ('k') | lib/compiler/implementation/warnings.dart » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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]);
}
}
« no previous file with comments | « lib/compiler/implementation/lib/mockimpl.dart ('k') | lib/compiler/implementation/warnings.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698