Index: dart/sdk/lib/_internal/compiler/implementation/resolution/members.dart |
diff --git a/dart/sdk/lib/_internal/compiler/implementation/resolution/members.dart b/dart/sdk/lib/_internal/compiler/implementation/resolution/members.dart |
index 6202dfbfc0ff289dd21c009501a80c13ed5b19a9..6e52485218e7478c23893f7e6d59794ec58dcfee 100644 |
--- a/dart/sdk/lib/_internal/compiler/implementation/resolution/members.dart |
+++ b/dart/sdk/lib/_internal/compiler/implementation/resolution/members.dart |
@@ -492,12 +492,41 @@ class ResolverTask extends CompilerTask { |
MessageKind.ILLEGAL_CONSTRUCTOR_MODIFIERS.error([mismatchedFlags]), |
Diagnostic.ERROR); |
} |
+ checkConstructorNameHack(holder, member); |
} |
checkAbstractField(member); |
checkValidOverride(member, cls.lookupSuperMember(member.name)); |
}); |
} |
+ // TODO(ahe): Remove this method. It is only needed while we store |
+ // constructor names as ClassName$id. Once we start storing |
+ // constructors as just id, this will be caught by the general |
+ // mechanism for duplicate members. |
ngeoffray
2012/12/08 13:53:32
What makes it difficult to implement this today?
|
+ /// Check that a constructor name does not conflict with a member. |
+ void checkConstructorNameHack(ClassElement holder, FunctionElement member) { |
ngeoffray
2012/12/08 13:53:32
assert that member.getEnclosingClass() == holder?
|
+ // If the name of the constructor is the same as the name of the |
+ // class, there cannot be a problem. |
+ if (member.name == holder.name) return; |
+ |
+ SourceString name = |
+ Elements.deconstructConstructorName(member.name, holder); |
+ |
+ // If the name could not be deconstructed, this is is from a |
ngeoffray
2012/12/08 13:53:32
is is from a ... -> is a ...
|
+ // factory method from a deprecated interface implementation. |
+ if (name == null) return; |
+ |
+ Element otherMember = holder.lookupLocalMember(name); |
+ if (otherMember != null) { |
+ compiler.onDeprecatedFeature(member, 'conflicting constructor'); |
ngeoffray
2012/12/08 13:53:32
Something looks strange. Why are you implementing
|
+ compiler.reportMessage( |
+ compiler.spanFromElement(otherMember), |
+ MessageKind.GENERIC.error(['This member conflicts with a' |
+ ' constructor.']), |
+ Diagnostic.INFO); |
+ } |
+ } |
+ |
void checkAbstractField(Element member) { |
// Only check for getters. The test can only fail if there is both a setter |
// and a getter with the same name, and we only need to check each abstract |