Chromium Code Reviews| 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..a5cc401ac61b30e4ca1e198ca9051e9b9348ac47 100644 |
| --- a/sdk/lib/_internal/compiler/implementation/resolution/members.dart |
| +++ b/sdk/lib/_internal/compiler/implementation/resolution/members.dart |
| @@ -3098,11 +3098,33 @@ class ResolverVisitor extends MappingVisitor<Element> { |
| return null; |
| } |
| + void checkConstMapKeysDontOverrideEquals(Spannable spannable, |
| + MapConstant map) { |
| + List<Constant> keys = map.keys.entries; |
|
karlklose
2014/03/03 08:58:45
You can inline `keys`.
floitsch
2014/03/03 09:52:32
Done.
|
| + for (Constant key in keys) { |
| + 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. |