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

Unified Diff: pkg/compiler/lib/src/elements/modelx.dart

Issue 812523002: Change signature of lookupConstructor to only require a name. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: return null for unresolved default constructors Created 5 years, 11 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: pkg/compiler/lib/src/elements/modelx.dart
diff --git a/pkg/compiler/lib/src/elements/modelx.dart b/pkg/compiler/lib/src/elements/modelx.dart
index 0531a73146c188b08eaa188d423d28b1fa93db1f..631ed38c0388d5fec92b2d4af9a50a868a86a1db 100644
--- a/pkg/compiler/lib/src/elements/modelx.dart
+++ b/pkg/compiler/lib/src/elements/modelx.dart
@@ -2400,24 +2400,22 @@ abstract class BaseClassElementX extends ElementX
return false;
}
- Element validateConstructorLookupResults(Selector selector,
- Element result,
- Element noMatch(Element)) {
- if (result == null
- || !result.isConstructor
- || (isPrivateName(selector.name)
- && result.library != selector.library)) {
- result = noMatch != null ? noMatch(result) : null;
+ ConstructorElement lookupDefaultConstructor() {
+ ConstructorElement constructor = lookupConstructor("");
+ // This method might be called on constructors that have not been
+ // resolved. As we query the live world, we return `null` in such cases
+ // as no default constructor exists in the live world.
+ if (constructor != null &&
+ constructor.hasFunctionSignature &&
+ constructor.functionSignature.requiredParameterCount == 0) {
+ return constructor;
}
- return result;
+ return null;
}
- // TODO(aprelev@gmail.com): Peter believes that it would be great to
- // make noMatch a required argument. Peter's suspicion is that most
- // callers of this method would benefit from using the noMatch method.
- Element lookupConstructor(Selector selector, [Element noMatch(Element)]) {
- Element result = localLookup(selector.name);
- return validateConstructorLookupResults(selector, result, noMatch);
+ ConstructorElement lookupConstructor(String name) {
+ Element result = localLookup(name);
+ return result != null && result.isConstructor ? result : null;
}
Link<Element> get constructors {
« no previous file with comments | « pkg/compiler/lib/src/elements/elements.dart ('k') | pkg/compiler/lib/src/inferrer/concrete_types_inferrer.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698