Fixed Issue #465: tests for overriding with NNBD re-named and corrected. New tests added.
diff --git a/LanguageFeatures/nnbd/override_checking_A02_REQ_ARGS_t02.dart b/LanguageFeatures/nnbd/override_checking_A02_REQ_ARGS_t02.dart
index 5aaabaa..fe2acb8 100644
--- a/LanguageFeatures/nnbd/override_checking_A02_REQ_ARGS_t02.dart
+++ b/LanguageFeatures/nnbd/override_checking_A02_REQ_ARGS_t02.dart
@@ -19,20 +19,12 @@
import "override_checking_legacy_lib.dart";
-class A1 extends LEGACY_REQUIRED_ARGS {
+class A extends LEGACY_REQUIRED_ARGS {
void test_default({int? i}) {}
// ^^^^^^^^^^^^
// [analyzer] unspecified
// [cfe] unspecified
}
-
-abstract class A2 extends LEGACY_REQUIRED_ARGS {
- void test_default({int? i});
-// ^^^^^^^^^^^^
-// [analyzer] unspecified
-// [cfe] unspecified
-}
-
main() {
- A1().test_default(i: 1);
+ A().test_default(i: 1);
}
diff --git a/LanguageFeatures/nnbd/override_checking_A02_REQ_ARGS_t04.dart b/LanguageFeatures/nnbd/override_checking_A02_REQ_ARGS_t04.dart
index 0969ad2..58909aa 100644
--- a/LanguageFeatures/nnbd/override_checking_A02_REQ_ARGS_t04.dart
+++ b/LanguageFeatures/nnbd/override_checking_A02_REQ_ARGS_t04.dart
@@ -35,9 +35,6 @@
// [cfe] unspecified
void test_nondefault({int? i}) {}
-// ^^^^^^^^^^^^^^^
-// [analyzer] unspecified
-// [cfe] unspecified
}
main() {
diff --git a/LanguageFeatures/nnbd/override_checking_A02_REQ_ARGS_t08.dart b/LanguageFeatures/nnbd/override_checking_A02_REQ_ARGS_t08.dart
index 1efe137..7c47af1 100644
--- a/LanguageFeatures/nnbd/override_checking_A02_REQ_ARGS_t08.dart
+++ b/LanguageFeatures/nnbd/override_checking_A02_REQ_ARGS_t08.dart
@@ -21,7 +21,7 @@
abstract class B {
void test_default({required int? i}) {}
- void test_nondefault({required int? i}) {}
+ void test_nondefault({int? i}) {}
}
class A implements B, LEGACY_REQUIRED_ARGS {
@@ -31,12 +31,8 @@
// [cfe] unspecified
void test_nondefault({int? i}) {}
-// ^^^^^^^^^^^^^^^
-// [analyzer] unspecified
-// [cfe] unspecified
}
main() {
A().test_default(i: 1);
- A().test_nondefault(i: 1);
}
diff --git a/LanguageFeatures/nnbd/override_checking_A02_REQ_ARGS_t09.dart b/LanguageFeatures/nnbd/override_checking_A02_REQ_ARGS_t09.dart
index 849835b..cc1971c 100644
--- a/LanguageFeatures/nnbd/override_checking_A02_REQ_ARGS_t09.dart
+++ b/LanguageFeatures/nnbd/override_checking_A02_REQ_ARGS_t09.dart
@@ -10,26 +10,19 @@
* to override otherwise incompatible signatures for a method.
*
* @description Check that if opted-in class extends legacy class, migrated
- * method with required non-nullable parameter cannot override legacy method
+ * method with required non-nullable parameter can override legacy method
* with named parameter (which is nullable) with and without default value.
- * @Issue 39678
*
* @author iarkh@unipro.ru
*/
// SharedOptions=--enable-experiment=non-nullable
import "override_checking_legacy_lib.dart";
+import "../../Utils/expect.dart";
class A extends LEGACY_REQUIRED_ARGS {
- void test_default({required int i}) {}
-// ^^^^^^^^^^^^
-// [analyzer] unspecified
-// [cfe] unspecified
-
- void test_nondefault({required int i}) {}
-// ^^^^^^^^^^^^^^^
-// [analyzer] unspecified
-// [cfe] unspecified
+ void test_default({required int i}) { Expect.equals(1, i); }
+ void test_nondefault({required int i}) { Expect.equals(1, i); }
}
main() {
diff --git a/LanguageFeatures/nnbd/override_checking_A02_REQ_ARGS_t11.dart b/LanguageFeatures/nnbd/override_checking_A02_REQ_ARGS_t11.dart
index 424840b..41656ad 100644
--- a/LanguageFeatures/nnbd/override_checking_A02_REQ_ARGS_t11.dart
+++ b/LanguageFeatures/nnbd/override_checking_A02_REQ_ARGS_t11.dart
@@ -10,8 +10,8 @@
* to override otherwise incompatible signatures for a method.
*
* @description Check that if opted-in class implements legacy class, migrated
- * method with required non-nullable parameter cannot override legacy method
- * with named parameter (which is nullable) with and without default value.
+ * method with required non-nullable parameter can override legacy method with
+ * named parameter (which is nullable) with and without default value.
* @Issue 39678
*
* @author iarkh@unipro.ru
@@ -19,17 +19,11 @@
// SharedOptions=--enable-experiment=non-nullable
import "override_checking_legacy_lib.dart";
+import "../../Utils/expect.dart";
class A implements LEGACY_REQUIRED_ARGS {
- void test_default({required int i}) {}
-// ^^^^^^^^^^^^
-// [analyzer] unspecified
-// [cfe] unspecified
-
- void test_nondefault({required int i}) {}
-// ^^^^^^^^^^^^^^^
-// [analyzer] unspecified
-// [cfe] unspecified
+ void test_default({required int i}) { Expect.equals(1, i); }
+ void test_nondefault({required int i}) { Expect.equals(1, i); }
}
main() {
diff --git a/LanguageFeatures/nnbd/override_checking_A02_REQ_ARGS_t13.dart b/LanguageFeatures/nnbd/override_checking_A02_REQ_ARGS_t13.dart
index 6c60cb0..78a4879 100644
--- a/LanguageFeatures/nnbd/override_checking_A02_REQ_ARGS_t13.dart
+++ b/LanguageFeatures/nnbd/override_checking_A02_REQ_ARGS_t13.dart
@@ -10,27 +10,20 @@
* to override otherwise incompatible signatures for a method.
*
* @description Check that if opted-in class is a mixin with a legacy class,
- * migrated method with required non-nullable parameter cannot override legacy
+ * migrated method with required non-nullable parameter can override legacy
* method with named parameter (which is nullable) with and without default
* value.
- * @Issue 39678
*
* @author iarkh@unipro.ru
*/
// SharedOptions=--enable-experiment=non-nullable
import "override_checking_legacy_lib.dart";
+import "../../Utils/expect.dart";
-class A with LEGACY_REQUIRED_ARGS {
- void test_default({required int i}) {}
-// ^^^^^^^^^^^^
-// [analyzer] unspecified
-// [cfe] unspecified
-
- void test_nondefault({required int i}) {}
-// ^^^^^^^^^^^^^^^
-// [analyzer] unspecified
-// [cfe] unspecified
+class A implements LEGACY_REQUIRED_ARGS {
+ void test_default({required int i}) { Expect.equals(1, i); }
+ void test_nondefault({required int i}) { Expect.equals(1, i); }
}
main() {
diff --git a/LanguageFeatures/nnbd/override_checking_A02_REQ_ARGS_t15.dart b/LanguageFeatures/nnbd/override_checking_A02_REQ_ARGS_t15.dart
index 66c3c80..0d33ba5 100644
--- a/LanguageFeatures/nnbd/override_checking_A02_REQ_ARGS_t15.dart
+++ b/LanguageFeatures/nnbd/override_checking_A02_REQ_ARGS_t15.dart
@@ -11,15 +11,15 @@
*
* @description Check that if opted-in class implements two classes with some
* method (one is legacy), migrated method with required non-nullable parameter
- * cannot override legacy method with named parameter (which is nullable) with
+ * can override legacy method with named parameter (which is nullable) with
* default value.
- * @Issue 39678
*
* @author iarkh@unipro.ru
*/
// SharedOptions=--enable-experiment=non-nullable
import "override_checking_legacy_lib.dart";
+import "../../Utils/expect.dart";
abstract class B {
void test_default({required int i}) {}
@@ -27,15 +27,8 @@
}
class A implements B, LEGACY_REQUIRED_ARGS {
- void test_default({required int i}) {}
-// ^^^^^^^^^^^^
-// [analyzer] unspecified
-// [cfe] unspecified
-
- void test_nondefault({required int i}) {}
-// ^^^^^^^^^^^^^^^
-// [analyzer] unspecified
-// [cfe] unspecified
+ void test_default({required int i}) { Expect.equals(1, i); }
+ void test_nondefault({required int i}) { Expect.equals(1, i); }
}
main() {
diff --git a/LanguageFeatures/nnbd/override_checking_A02_REQ_ARGS_t17.dart b/LanguageFeatures/nnbd/override_checking_A02_REQ_ARGS_t17.dart
new file mode 100644
index 0000000..7b7b47c
--- /dev/null
+++ b/LanguageFeatures/nnbd/override_checking_A02_REQ_ARGS_t17.dart
@@ -0,0 +1,35 @@
+/*
+ * Copyright (c) 2019, the Dart project authors. Please see the AUTHORS file
+ * for details. All rights reserved. Use of this source code is governed by a
+ * BSD-style license that can be found in the LICENSE file.
+ */
+/**
+ * @assertion In a migrated library, override checking must check that an
+ * override is consistent with all overridden methods from other migrated
+ * libraries in the super-interface chain, since a legacy library is permitted
+ * to override otherwise incompatible signatures for a method.
+ *
+ * @description Check that if opted-in class extends legacy class, migrated
+ * method with non-required nullable parameter can override legacy method
+ * with named parameter without default value.
+ *
+ * @author iarkh@unipro.ru
+ */
+// SharedOptions=--enable-experiment=non-nullable
+
+import "override_checking_legacy_lib.dart";
+import "../../Utils/expect.dart";
+
+
+class A1 extends LEGACY_REQUIRED_ARGS {
+ void test_nondefault({int? i}) { Expect.equals(1, i); }
+}
+
+class A2 extends LEGACY_REQUIRED_ARGS {
+ void test_nondefault({int? i}) { Expect.isNull(i); }
+}
+
+main() {
+ A1().test_nondefault(i: 1);
+ A2().test_nondefault();
+}
diff --git a/LanguageFeatures/nnbd/override_checking_A02_REQ_ARGS_t18.dart b/LanguageFeatures/nnbd/override_checking_A02_REQ_ARGS_t18.dart
new file mode 100644
index 0000000..34c9d10
--- /dev/null
+++ b/LanguageFeatures/nnbd/override_checking_A02_REQ_ARGS_t18.dart
@@ -0,0 +1,36 @@
+/*
+ * Copyright (c) 2019, the Dart project authors. Please see the AUTHORS file
+ * for details. All rights reserved. Use of this source code is governed by a
+ * BSD-style license that can be found in the LICENSE file.
+ */
+/**
+ * @assertion In a migrated library, override checking must check that an
+ * override is consistent with all overridden methods from other migrated
+ * libraries in the super-interface chain, since a legacy library is permitted
+ * to override otherwise incompatible signatures for a method.
+ *
+ * @description Check that if opted-in class implements legacy class, migrated
+ * method with non-required nullable parameter can override legacy method
+ * with named parameter without default value.
+ *
+ * @author iarkh@unipro.ru
+ */
+// SharedOptions=--enable-experiment=non-nullable
+
+import "override_checking_legacy_lib.dart";
+import "../../Utils/expect.dart";
+
+class A1 implements LEGACY_REQUIRED_ARGS {
+ void test_default({required int? i}) {}
+ void test_nondefault({int? i}) { Expect.equals(1, i); }
+}
+
+class A2 implements LEGACY_REQUIRED_ARGS {
+ void test_default({required int? i}) {}
+ void test_nondefault({int? i}) { Expect.isNull(i);}
+}
+
+main() {
+ A1().test_nondefault(i: 1);
+ A2().test_nondefault();
+}
diff --git a/LanguageFeatures/nnbd/override_checking_A02_REQ_ARGS_t19.dart b/LanguageFeatures/nnbd/override_checking_A02_REQ_ARGS_t19.dart
new file mode 100644
index 0000000..db214de
--- /dev/null
+++ b/LanguageFeatures/nnbd/override_checking_A02_REQ_ARGS_t19.dart
@@ -0,0 +1,34 @@
+/*
+ * Copyright (c) 2019, the Dart project authors. Please see the AUTHORS file
+ * for details. All rights reserved. Use of this source code is governed by a
+ * BSD-style license that can be found in the LICENSE file.
+ */
+/**
+ * @assertion In a migrated library, override checking must check that an
+ * override is consistent with all overridden methods from other migrated
+ * libraries in the super-interface chain, since a legacy library is permitted
+ * to override otherwise incompatible signatures for a method.
+ *
+ * @description Check that if opted-in class is a mixin with a legacy class,
+ * migrated method with non-required nullable parameter can override legacy
+ * method without named parameter with default value.
+ *
+ * @author iarkh@unipro.ru
+ */
+// SharedOptions=--enable-experiment=non-nullable
+
+import "override_checking_legacy_lib.dart";
+import "../../Utils/expect.dart";
+
+class A1 with LEGACY_REQUIRED_ARGS {
+ void test_nondefault({int? i}) { Expect.equals(1, i); }
+}
+
+class A2 with LEGACY_REQUIRED_ARGS {
+ void test_nondefault({int? i}) { Expect.isNull(i); }
+}
+
+main() {
+ A1().test_nondefault(i: 1);
+ A2().test_nondefault();
+}
diff --git a/LanguageFeatures/nnbd/override_checking_A02_REQ_ARGS_t20.dart b/LanguageFeatures/nnbd/override_checking_A02_REQ_ARGS_t20.dart
new file mode 100644
index 0000000..a666c23
--- /dev/null
+++ b/LanguageFeatures/nnbd/override_checking_A02_REQ_ARGS_t20.dart
@@ -0,0 +1,41 @@
+/*
+ * Copyright (c) 2019, the Dart project authors. Please see the AUTHORS file
+ * for details. All rights reserved. Use of this source code is governed by a
+ * BSD-style license that can be found in the LICENSE file.
+ */
+/**
+ * @assertion In a migrated library, override checking must check that an
+ * override is consistent with all overridden methods from other migrated
+ * libraries in the super-interface chain, since a legacy library is permitted
+ * to override otherwise incompatible signatures for a method.
+ *
+ * @description Check that if opted-in class implements two classes with some
+ * method (one is legacy), migrated method with non-required nullable parameter
+ * cannot override legacy method with named parameter with default value.
+ *
+ * @author iarkh@unipro.ru
+ */
+// SharedOptions=--enable-experiment=non-nullable
+
+import "override_checking_legacy_lib.dart";
+import "../../Utils/expect.dart";
+
+abstract class B {
+ void test_default({required int? i}) {}
+ void test_nondefault({int? i}) {}
+}
+
+class A1 implements B, LEGACY_REQUIRED_ARGS {
+ void test_default({required int? i}) {}
+ void test_nondefault({int? i}) { Expect.equals(1, i); }
+}
+
+class A2 implements B, LEGACY_REQUIRED_ARGS {
+ void test_default({required int? i}) {}
+ void test_nondefault({int? i}) { Expect.isNull(i);}
+}
+
+main() {
+ A1().test_nondefault(i: 1);
+ A2().test_nondefault();
+}