Index: sdk/lib/_internal/compiler/implementation/resolution/members.dart |
diff --git a/sdk/lib/_internal/compiler/implementation/resolution/members.dart b/sdk/lib/_internal/compiler/implementation/resolution/members.dart |
index 69e3b45b9d02d08514b558f3b894906b061ee331..1ea01a85e38bdbc3d007b9cf76a1c7b54b4d5018 100644 |
--- a/sdk/lib/_internal/compiler/implementation/resolution/members.dart |
+++ b/sdk/lib/_internal/compiler/implementation/resolution/members.dart |
@@ -3098,11 +3098,32 @@ class ResolverVisitor extends MappingVisitor<Element> { |
return null; |
} |
+ void checkConstMapKeysDontOverrideEquals(Spannable spannable, |
+ MapConstant map) { |
+ for (Constant key in map.keys.entries) { |
+ if (!key.isObject()) continue; |
+ ObjectConstant objectConstant = key; |
+ DartType keyType = objectConstant.type; |
+ ClassElement cls = keyType.element; |
+ if (cls == compiler.stringClass) continue; |
+ Element equals = cls.lookupMember('=='); |
+ if (equals.getEnclosingClass() != compiler.objectClass) { |
+ compiler.reportError(spannable, |
+ MessageKind.CONST_MAP_KEY_OVERRIDES_EQUALS, |
+ {'type': keyType}); |
+ } |
+ } |
+ } |
+ |
void analyzeConstant(Node node, {bool isConst: true}) { |
addDeferredAction(enclosingElement, () { |
Constant constant = compiler.constantHandler.compileNodeWithDefinitions( |
node, mapping, isConst: isConst); |
+ if (isConst && constant != null && constant.isMap()) { |
+ checkConstMapKeysDontOverrideEquals(node, constant); |
+ } |
+ |
// The type constant that is an argument to JS_INTERCEPTOR_CONSTANT names |
// a class that will be instantiated outside the program by attaching a |
// native class dispatch record referencing the interceptor. |