Adjusted method_override_test to eliminate spurious compile time error
Change-Id: I1f46f28c220ba2a6d5c5e3dc4f2c3efd010c7a8a
Reviewed-on: https://dart-review.googlesource.com/68664
Reviewed-by: Kevin Millikin <kmillikin@google.com>
Commit-Queue: Erik Ernst <eernst@google.com>
diff --git a/tests/language_2/language_2_analyzer.status b/tests/language_2/language_2_analyzer.status
index 2cc1a90..4d4b5b3 100644
--- a/tests/language_2/language_2_analyzer.status
+++ b/tests/language_2/language_2_analyzer.status
@@ -73,8 +73,6 @@
invalid_type_argument_count_test/03: MissingCompileTimeError
invalid_type_argument_count_test/04: MissingCompileTimeError
method_override7_test/03: Fail # Issue 11497
-method_override_test: CompileTimeError
-method_override_test: StaticWarning
mixin_supertype_subclass2_test/02: MissingStaticWarning # Issue 25614
mixin_supertype_subclass2_test/05: MissingStaticWarning # Issue 25614
mixin_supertype_subclass3_test/02: MissingStaticWarning # Issue 25614
diff --git a/tests/language_2/language_2_dart2js.status b/tests/language_2/language_2_dart2js.status
index b7eb8ea..532ac80 100644
--- a/tests/language_2/language_2_dart2js.status
+++ b/tests/language_2/language_2_dart2js.status
@@ -897,7 +897,6 @@
local_function2_test/none: RuntimeError
local_function3_test/none: RuntimeError
local_function_test/none: RuntimeError
-method_override_test: CompileTimeError
minify_closure_variable_collision_test: CompileTimeError
mint_arithmetic_test: RuntimeError # non JS number semantics
mixin_forwarding_constructor4_test/01: MissingCompileTimeError
diff --git a/tests/language_2/language_2_dartdevc.status b/tests/language_2/language_2_dartdevc.status
index 0d6f418..46b29f0 100644
--- a/tests/language_2/language_2_dartdevc.status
+++ b/tests/language_2/language_2_dartdevc.status
@@ -100,7 +100,6 @@
label_test: RuntimeError
left_shift_test: RuntimeError # Ints and doubles are unified.
method_override7_test/03: MissingCompileTimeError
-method_override_test: CompileTimeError # Negative test
mixin_super_2_test/01: MissingCompileTimeError
mixin_super_2_test/03: MissingCompileTimeError
mixin_super_test: RuntimeError
@@ -325,7 +324,6 @@
map_literal3_test/01: MissingCompileTimeError
map_literal3_test/02: MissingCompileTimeError
map_literal3_test/03: MissingCompileTimeError
-method_override_test: CompileTimeError # Issue 31616
mixin_forwarding_constructor4_test/01: MissingCompileTimeError
mixin_forwarding_constructor4_test/02: MissingCompileTimeError
mixin_forwarding_constructor4_test/03: MissingCompileTimeError
diff --git a/tests/language_2/language_2_kernel.status b/tests/language_2/language_2_kernel.status
index 36095f6..93ba1ca 100644
--- a/tests/language_2/language_2_kernel.status
+++ b/tests/language_2/language_2_kernel.status
@@ -88,7 +88,6 @@
local_function3_test/none: RuntimeError
local_function_test/none: RuntimeError
main_test/03: RuntimeError
-method_override_test: CompileTimeError # Issue 31616 --- note that this test cannot be expected to pass in its current state!
mixin_illegal_super_use_test/01: MissingCompileTimeError
mixin_illegal_super_use_test/04: MissingCompileTimeError
mixin_illegal_super_use_test/07: MissingCompileTimeError
@@ -863,7 +862,6 @@
method_override6_test/01: MissingCompileTimeError
method_override6_test/02: MissingCompileTimeError
method_override6_test/03: MissingCompileTimeError
-method_override_test: CompileTimeError # Issue 31616 --- note that this test cannot be expected to pass in its current state!
mixin_illegal_super_use_test: Skip # Issues 24478 and 23773
mixin_illegal_superclass_test: Skip # Issues 24478 and 23773
named_parameters_default_eq_test/none: RuntimeError
@@ -983,7 +981,6 @@
instantiate_tearoff_of_call_test: CompileTimeError
issue31596_super_test/01: CompileTimeError
issue31596_super_test/03: CompileTimeError
-method_override_test: CompileTimeError # Issue 31616 --- note that this test cannot be expected to pass in its current state!
mixin_illegal_super_use_test/01: MissingCompileTimeError
mixin_illegal_super_use_test/04: MissingCompileTimeError
mixin_illegal_super_use_test/07: MissingCompileTimeError
@@ -1454,7 +1451,6 @@
method_override6_test/01: MissingCompileTimeError
method_override6_test/02: MissingCompileTimeError
method_override6_test/03: MissingCompileTimeError
-method_override_test: CompileTimeError # Issue 31616 --- note that this test cannot be expected to pass in its current state!
mixin_illegal_super_use_test: Skip # Issues 24478 and 23773
mixin_illegal_superclass_test: Skip # Issues 24478 and 23773
named_constructor_test/01: MissingRuntimeError # Fasta bug: Bad compilation of constructor reference.
diff --git a/tests/language_2/method_override_test.dart b/tests/language_2/method_override_test.dart
index fe3b686..1a09455 100644
--- a/tests/language_2/method_override_test.dart
+++ b/tests/language_2/method_override_test.dart
@@ -9,14 +9,17 @@
typedef V RemoveFunctionType<K, V>(K key);
-class MapBase<K, V> implements Map<K, V> {
+class MapBase<K, V> {
K remove(K key) {
throw 'Must be implemented';
}
- void Tests() {
+ void tests() {
Expect.isTrue(this is MapBase<int, int>);
+ // `remove` takes an argument which is covariant-by-class, so
+ // the tear-off has dynamic type `int Function(Object)`.
+
Expect.isTrue(remove is RemoveFunctionType);
Expect.isTrue(remove is RemoveFunctionType<int, int>);
Expect.isTrue(remove is RemoveFunctionType<String, int>);
@@ -29,10 +32,14 @@
throw 'Must be implemented';
}
- void Tests() {
+ void tests() {
Expect.isTrue(this is MethodOverrideTest);
Expect.isTrue(this is MapBase<String, String>);
+ // `remove` takes an argument which is covariant-by-class because
+ // an overridden method does so, and hence the tear-off has dynamic
+ // type `String Function(Object)`; so does `super.remove`.
+
Expect.isTrue(remove is RemoveFunctionType);
Expect.isTrue(remove is RemoveFunctionType<String, String>);
Expect.isTrue(remove is! RemoveFunctionType<int, int>);
@@ -43,17 +50,6 @@
}
main() {
- // Since method overriding is only checked statically, explicitly check
- // the subtyping relation using a function type alias.
- var x = new MethodOverrideTest();
- Expect.isTrue(x.remove is RemoveFunctionType<String, String>);
-
- // Perform a few more tests.
- x.Tests();
-
- var m = new MapBase<int, int>();
- Expect.isTrue(m.remove is RemoveFunctionType<int, int>);
-
- // Perform a few more tests.
- m.Tests();
+ new MapBase<int, int>().tests();
+ new MethodOverrideTest().tests();
}