[tests] Allow using classes as mixins within the same library and update a few language tests.

Change-Id: I4488b3ee7d04fe3a9c34ee3046f96e73984c0541
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/274602
Commit-Queue: Kallen Tu <kallentu@google.com>
Reviewed-by: Bob Nystrom <rnystrom@google.com>
This commit is contained in:
Kallen Tu 2022-12-13 18:29:58 +00:00 committed by Commit Queue
parent 35f0bb8187
commit 93c3737674
7 changed files with 41 additions and 27 deletions

View file

@ -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.

View file

@ -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 {}

View file

@ -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;

View file

@ -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.

View file

@ -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.

View file

@ -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.

View file

@ -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.