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

Unified Diff: dart/tests/compiler/dart2js/resolver_test.dart

Issue 17588005: Warn about overriding operator== but not hashCode. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge
Patch Set: Created 7 years, 6 months 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: dart/tests/compiler/dart2js/resolver_test.dart
diff --git a/dart/tests/compiler/dart2js/resolver_test.dart b/dart/tests/compiler/dart2js/resolver_test.dart
index dcdcc070919b5386c606a65aee86a8e0d309f712..1902d65337bc1f47e60112c9a5bfa401ddc7c280 100644
--- a/dart/tests/compiler/dart2js/resolver_test.dart
+++ b/dart/tests/compiler/dart2js/resolver_test.dart
@@ -74,6 +74,7 @@ main() {
testToString();
testIndexedOperator();
testIncrementsAndDecrements();
+ testOverrideHashCodeCheck();
}
testTypeVariables() {
@@ -845,3 +846,22 @@ testIncrementsAndDecrements() {
checkMemberResolved(compiler, 'C', operatorName('-', false));
checkMemberResolved(compiler, 'D', operatorName('-', false));
}
+
+testOverrideHashCodeCheck() {
+ final script = r"""
+ class A {
+ operator==(other) => true;
+ }
+ class B {
+ operator==(other) => true;
+ get hashCode => 0;
+ }
+ main() {
+ new A() == new B();
+ }""";
+ final compiler = compileScript(script);
+ Expect.equals(1, compiler.warnings.length);
+ Expect.equals(MessageKind.OVERRIDE_EQUALS_NOT_HASH_CODE,
+ compiler.warnings[0].message.kind);
+ Expect.equals(0, compiler.errors.length);
+}

Powered by Google App Engine
This is Rietveld 408576698