| OLD | NEW |
| 1 // Copyright (c) 2012, the Dart project authors. Please see the AUTHORS file | 1 // Copyright (c) 2012, the Dart project authors. Please see the AUTHORS file |
| 2 // for details. All rights reserved. Use of this source code is governed by a | 2 // for details. All rights reserved. Use of this source code is governed by a |
| 3 // BSD-style license that can be found in the LICENSE file. | 3 // BSD-style license that can be found in the LICENSE file. |
| 4 | 4 |
| 5 import "package:expect/expect.dart"; | 5 import "package:expect/expect.dart"; |
| 6 import 'dart:collection'; | 6 import 'dart:collection'; |
| 7 | 7 |
| 8 import "../../../sdk/lib/_internal/compiler/implementation/resolution/resolution
.dart"; | 8 import "../../../sdk/lib/_internal/compiler/implementation/resolution/resolution
.dart"; |
| 9 import "compiler_helper.dart"; | 9 import "compiler_helper.dart"; |
| 10 import "parser_helper.dart"; | 10 import "parser_helper.dart"; |
| (...skipping 56 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 67 testNewExpression(); | 67 testNewExpression(); |
| 68 testTopLevelFields(); | 68 testTopLevelFields(); |
| 69 testClassHierarchy(); | 69 testClassHierarchy(); |
| 70 testInitializers(); | 70 testInitializers(); |
| 71 testThis(); | 71 testThis(); |
| 72 testSuperCalls(); | 72 testSuperCalls(); |
| 73 testTypeVariables(); | 73 testTypeVariables(); |
| 74 testToString(); | 74 testToString(); |
| 75 testIndexedOperator(); | 75 testIndexedOperator(); |
| 76 testIncrementsAndDecrements(); | 76 testIncrementsAndDecrements(); |
| 77 testOverrideHashCodeCheck(); |
| 77 } | 78 } |
| 78 | 79 |
| 79 testTypeVariables() { | 80 testTypeVariables() { |
| 80 matchResolvedTypes(visitor, text, name, expectedElements) { | 81 matchResolvedTypes(visitor, text, name, expectedElements) { |
| 81 VariableDefinitions definition = parseStatement(text); | 82 VariableDefinitions definition = parseStatement(text); |
| 82 visitor.visit(definition.type); | 83 visitor.visit(definition.type); |
| 83 InterfaceType type = visitor.mapping.getType(definition.type); | 84 InterfaceType type = visitor.mapping.getType(definition.type); |
| 84 Expect.equals(definition.type.typeArguments.slowLength(), | 85 Expect.equals(definition.type.typeArguments.slowLength(), |
| 85 length(type.typeArguments)); | 86 length(type.typeArguments)); |
| 86 int index = 0; | 87 int index = 0; |
| (...skipping 751 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 838 var d = new D(); | 839 var d = new D(); |
| 839 --d; | 840 --d; |
| 840 }"""; | 841 }"""; |
| 841 final compiler = compileScript(script); | 842 final compiler = compileScript(script); |
| 842 | 843 |
| 843 checkMemberResolved(compiler, 'A', operatorName('+', false)); | 844 checkMemberResolved(compiler, 'A', operatorName('+', false)); |
| 844 checkMemberResolved(compiler, 'B', operatorName('+', false)); | 845 checkMemberResolved(compiler, 'B', operatorName('+', false)); |
| 845 checkMemberResolved(compiler, 'C', operatorName('-', false)); | 846 checkMemberResolved(compiler, 'C', operatorName('-', false)); |
| 846 checkMemberResolved(compiler, 'D', operatorName('-', false)); | 847 checkMemberResolved(compiler, 'D', operatorName('-', false)); |
| 847 } | 848 } |
| 849 |
| 850 testOverrideHashCodeCheck() { |
| 851 final script = r""" |
| 852 class A { |
| 853 operator==(other) => true; |
| 854 } |
| 855 class B { |
| 856 operator==(other) => true; |
| 857 get hashCode => 0; |
| 858 } |
| 859 main() { |
| 860 new A() == new B(); |
| 861 }"""; |
| 862 final compiler = compileScript(script); |
| 863 Expect.equals(1, compiler.warnings.length); |
| 864 Expect.equals(MessageKind.OVERRIDE_EQUALS_NOT_HASH_CODE, |
| 865 compiler.warnings[0].message.kind); |
| 866 Expect.equals(0, compiler.errors.length); |
| 867 } |
| OLD | NEW |