diff --git a/tests/language/sealed_class/sealed_class_as_mixin_in_lib_error_test.dart b/tests/language/sealed_class/sealed_class_as_mixin_in_lib_test.dart similarity index 52% rename from tests/language/sealed_class/sealed_class_as_mixin_in_lib_error_test.dart rename to tests/language/sealed_class/sealed_class_as_mixin_in_lib_test.dart index 12dec23c4a8..156a091033d 100644 --- a/tests/language/sealed_class/sealed_class_as_mixin_in_lib_error_test.dart +++ b/tests/language/sealed_class/sealed_class_as_mixin_in_lib_test.dart @@ -4,7 +4,7 @@ // SharedOptions=--enable-experiment=sealed-class -// Error when attempting to mix in a sealed class inside of library. +// Allow mixing in a sealed class inside of library. sealed class SealedClass { int nonAbstractFoo = 0; @@ -17,14 +17,8 @@ class Class {} mixin Mixin {} abstract class A with SealedClass {} -// ^ -// [analyzer] unspecified -// [cfe] Class 'SealedClass' can't be used as a mixin. class B with SealedClass { -// ^ -// [analyzer] unspecified -// [cfe] Class 'SealedClass' can't be used as a mixin. @override int nonAbstractFoo = 100; @@ -36,27 +30,11 @@ class B with SealedClass { } abstract class C = Object with SealedClass; -// ^ -// [analyzer] unspecified -// [cfe] Class 'SealedClass' can't be used as a mixin. abstract class D with SealedClass, Class {} -// ^ -// [analyzer] unspecified -// [cfe] Class 'Class' can't be used as a mixin. -// [cfe] Class 'SealedClass' can't be used as a mixin. class E with Class, SealedMixin {} -// ^ -// [analyzer] unspecified -// [cfe] Class 'Class' can't be used as a mixin. abstract class F with Mixin, SealedClass {} -// ^ -// [analyzer] unspecified -// [cfe] Class 'SealedClass' can't be used as a mixin. class G with Mixin, Class {} -// ^ -// [analyzer] unspecified -// [cfe] Class 'Class' can't be used as a mixin. diff --git a/tests/language/sealed_class/sealed_class_as_mixin_old_version_lib.dart b/tests/language/sealed_class/sealed_class_as_mixin_old_version_lib.dart new file mode 100644 index 00000000000..327bdca9485 --- /dev/null +++ b/tests/language/sealed_class/sealed_class_as_mixin_old_version_lib.dart @@ -0,0 +1,9 @@ +// Copyright (c) 2022, 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. + +// @dart = 2.18 + +class Class {} + +mixin Mixin {} diff --git a/tests/language/sealed_class/sealed_class_as_mixin_old_version_test.dart b/tests/language/sealed_class/sealed_class_as_mixin_old_version_test.dart new file mode 100644 index 00000000000..c67dc6af76f --- /dev/null +++ b/tests/language/sealed_class/sealed_class_as_mixin_old_version_test.dart @@ -0,0 +1,27 @@ +// Copyright (c) 2022, 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. + +// SharedOptions=--enable-experiment=sealed-class + +// Allow mixing in a sealed class outside of library when the version of the +// library of the class being mixed-in is older than the version that +// `sealed-class` is being shipped in. + +import 'sealed_class_as_mixin_old_version_lib.dart'; + +abstract class OutsideA with Class {} + +class OutsideB with Class {} + +class OutsideC = Object with Class; + +abstract class OutsideD with Class, Mixin {} + +class OutsideE with Class, Mixin {} + +sealed class OutsideF with Class {} + +sealed class OutsideG with Class, Mixin {} + +sealed class OutsideH = Object with Class; diff --git a/tests/language/sealed_class/sealed_class_implement_error_test.dart b/tests/language/sealed_class/sealed_class_implement_error_test.dart index c8fda06a358..8ce0a955ef5 100644 --- a/tests/language/sealed_class/sealed_class_implement_error_test.dart +++ b/tests/language/sealed_class/sealed_class_implement_error_test.dart @@ -15,7 +15,7 @@ abstract class OutsideA implements SealedClass {} // [cfe] Sealed class 'SealedClass' can't be extended, implemented, or mixed in outside of its library. class OutsideB implements SealedClass { -// [error column 1, length 344] +// [error column 1, length 423] // [analyzer] COMPILE_TIME_ERROR.SEALED_CLASS_SUBTYPE_OUTSIDE_OF_LIBRARY // ^ // [cfe] Sealed class 'SealedClass' can't be extended, implemented, or mixed in outside of its library. diff --git a/tests/language/sealed_class/sealed_class_typedef_error_test.dart b/tests/language/sealed_class/sealed_class_typedef_error_test.dart index 8535f9fb51c..58c0a9a1875 100644 --- a/tests/language/sealed_class/sealed_class_typedef_error_test.dart +++ b/tests/language/sealed_class/sealed_class_typedef_error_test.dart @@ -16,7 +16,7 @@ class ATypeDef extends SealedClassTypeDef {} // [cfe] Sealed class 'SealedClass' can't be extended, implemented, or mixed in outside of its library. class BTypeDef implements SealedClassTypeDef { -// [error column 1, length 213] +// [error column 1, length 292] // [analyzer] COMPILE_TIME_ERROR.SEALED_CLASS_SUBTYPE_OUTSIDE_OF_LIBRARY // ^ // [cfe] Sealed class 'SealedClass' can't be extended, implemented, or mixed in outside of its library. diff --git a/tests/language/sealed_class/sealed_class_typedef_used_outside_error_test.dart b/tests/language/sealed_class/sealed_class_typedef_used_outside_error_test.dart index 7bb6707552e..4c49f63b3de 100644 --- a/tests/language/sealed_class/sealed_class_typedef_used_outside_error_test.dart +++ b/tests/language/sealed_class/sealed_class_typedef_used_outside_error_test.dart @@ -19,7 +19,7 @@ class A extends ATypeDef {} // [cfe] Sealed class 'SealedClass' can't be extended, implemented, or mixed in outside of its library. class B implements ATypeDef { -// [error column 1, length 184] +// [error column 1, length 263] // [analyzer] COMPILE_TIME_ERROR.SEALED_CLASS_SUBTYPE_OUTSIDE_OF_LIBRARY // ^ // [cfe] Sealed class 'SealedClass' can't be extended, implemented, or mixed in outside of its library. diff --git a/tests/language/sealed_class/sealed_mixin_with_error_test.dart b/tests/language/sealed_class/sealed_mixin_with_error_test.dart index 329aa930350..5a61176935d 100644 --- a/tests/language/sealed_class/sealed_mixin_with_error_test.dart +++ b/tests/language/sealed_class/sealed_mixin_with_error_test.dart @@ -15,7 +15,7 @@ abstract class OutsideA with SealedMixin {} // [cfe] Sealed mixin 'SealedMixin' can't be mixed in outside of its library. class OutsideB with SealedMixin { -// [error column 1, length 218] +// [error column 1, length 297] // [analyzer] COMPILE_TIME_ERROR.SEALED_MIXIN_SUBTYPE_OUTSIDE_OF_LIBRARY // ^ // [cfe] Sealed mixin 'SealedMixin' can't be mixed in outside of its library.