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

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

Issue 10947024: Made dart2js constructor lookup logic "private"-aware, fixed 4740 bug. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Another try in implementing constructor lookup, without SelectorName this time. Created 8 years, 3 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
Index: lib/compiler/implementation/resolver.dart
diff --git a/lib/compiler/implementation/resolver.dart b/lib/compiler/implementation/resolver.dart
index 3de67b305322f456a1d5ef3c13fef8c238b0f5ca..59bd65798eaab92a54d965565c1b741482d36d2e 100644
--- a/lib/compiler/implementation/resolver.dart
+++ b/lib/compiler/implementation/resolver.dart
@@ -105,7 +105,11 @@ class ResolverTask extends CompilerTask {
final SourceString constructorName =
getConstructorName(initializers.head);
final SourceString className = classElement.name;
- return classElement.lookupConstructor(className, constructorName);
+
+ return classElement.lookupConstructor(
+ new Selector.callConstructor(className,
+ constructorName,
+ constructor.getLibrary()));
kasperl 2012/09/24 05:52:38 I'm a bit worried about getting the library from v
aam-me 2012/09/25 04:15:18 Having helper function in the resolver (ResolverVi
}
return null;
}
@@ -202,7 +206,9 @@ class ResolverTask extends CompilerTask {
} else {
name = constructor.name;
}
- constructor.defaultImplementation = defaultClass.lookupConstructor(name);
+ constructor.defaultImplementation = defaultClass.lookupConstructor(
+ new Selector.callDefaultConstructor(name,
+ defaultClass.getLibrary()));
if (constructor.defaultImplementation === null) {
// We failed to find a constructor named either
@@ -609,17 +615,16 @@ class InitializerResolver {
// Lookup constructor and try to match it to the selector.
ResolverTask resolver = visitor.compiler.resolver;
final SourceString className = lookupTarget.name;
- result = lookupTarget.lookupConstructor(className, constructorName);
+ Selector lookupSelector =
+ new Selector.callConstructor(className,
kasperl 2012/09/24 05:52:38 4 space indent.
+ constructorName,
+ constructor.getLibrary());
+ result = lookupTarget.lookupConstructor(lookupSelector);
if (result === null || !result.isGenerativeConstructor()) {
- String classNameString = className.slowToString();
- String constructorNameString = constructorName.slowToString();
- String name = (constructorName === const SourceString(''))
- ? classNameString
- : "$classNameString.$constructorNameString";
MessageKind kind = isImplicitSuperCall
? MessageKind.CANNOT_RESOLVE_CONSTRUCTOR_FOR_IMPLICIT
: MessageKind.CANNOT_RESOLVE_CONSTRUCTOR;
- error(diagnosticNode, kind, [name]);
+ error(diagnosticNode, kind, [lookupSelector.name]);
} else {
if (!selector.applies(result, visitor.compiler)) {
MessageKind kind = isImplicitSuperCall
@@ -2647,17 +2652,16 @@ class ConstructorResolver extends CommonResolverVisitor<Element> {
Node diagnosticNode,
SourceString constructorName) {
cls.ensureResolved(compiler);
- Element result = cls.lookupConstructor(cls.name, constructorName);
+ Selector selector =
+ new Selector.callConstructor(cls.name,
+ constructorName,
+ resolver.enclosingElement.getLibrary());
+ Element result = cls.lookupConstructor(selector);
if (result === null) {
- String fullConstructorName = cls.name.slowToString();
- if (constructorName !== const SourceString('')) {
- fullConstructorName = '$fullConstructorName'
- '.${constructorName.slowToString()}';
- }
return failOrReturnErroneousElement(cls, diagnosticNode,
- new SourceString(fullConstructorName),
+ selector.name,
kasperl 2012/09/24 05:52:38 So there are two places where you need the full na
MessageKind.CANNOT_FIND_CONSTRUCTOR,
- [fullConstructorName]);
+ [selector.name.slowToString()]);
} else if (inConstContext &&
(result.modifiers == null || !result.modifiers.isConst())) {
error(diagnosticNode, MessageKind.CONSTRUCTOR_IS_NOT_CONST);

Powered by Google App Engine
This is Rietveld 408576698