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

Unified Diff: compiler/java/com/google/dart/compiler/resolver/MemberBuilder.java

Issue 11428131: More co19 triage. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Created 8 years 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: compiler/java/com/google/dart/compiler/resolver/MemberBuilder.java
diff --git a/compiler/java/com/google/dart/compiler/resolver/MemberBuilder.java b/compiler/java/com/google/dart/compiler/resolver/MemberBuilder.java
index 8953c4d90f47260354f147a60661b6cc4054b67b..a46aa61d2adf7ecc38df285d5f3c834c8a4def46 100644
--- a/compiler/java/com/google/dart/compiler/resolver/MemberBuilder.java
+++ b/compiler/java/com/google/dart/compiler/resolver/MemberBuilder.java
@@ -105,13 +105,35 @@ public class MemberBuilder {
member.accept(this);
}
}
- // check that constructor names don't conflict with member names
+ // check constructor names
for (ConstructorElement constructor : classElement.getConstructors()) {
String name = constructor.getName();
- Element member = classElement.lookupLocalElement(name);
- if (member != null) {
- resolutionError(constructor.getNameLocation(),
- ResolverErrorCode.CONSTRUCTOR_WITH_NAME_OF_MEMBER);
+ SourceInfo nameLocation = constructor.getNameLocation();
+ // should be name of immediately enclosing class
+ if (constructor.getModifiers().isFactory()) {
+ String rawName = constructor.getRawName();
+ String consClassName = StringUtils.substringBefore(rawName, ".");
+ String consUserName = StringUtils.substringAfter(rawName, ".");
+ if (!StringUtils.equals(consClassName, classElement.getName())) {
+ // report error for for M part of M.id or pure M
+ SourceInfo consClassLocation = new SourceInfo(nameLocation.getSource(),
+ nameLocation.getOffset(), consClassName.length());
+ resolutionError(consClassLocation,
+ ResolverErrorCode.CONSTRUCTOR_NAME_NOT_ENCLOSING_CLASS);
+ // in addition also report warning for whole constructor name
+ if (!StringUtils.isEmpty(consUserName)) {
+ resolutionError(nameLocation,
+ ResolverErrorCode.CONSTRUCTOR_NAME_NOT_ENCLOSING_CLASS_ID);
+ }
+ }
+ }
+ // should not conflict with member names
+ {
+ Element member = classElement.lookupLocalElement(name);
+ if (member != null) {
+ resolutionError(nameLocation,
+ ResolverErrorCode.CONSTRUCTOR_WITH_NAME_OF_MEMBER);
+ }
}
}
// done with this class

Powered by Google App Engine
This is Rietveld 408576698