mirror of
https://github.com/dart-lang/sdk
synced 2024-10-04 16:54:55 +00:00
[tests] Remove interface mixin, final mixin, and sealed mixin from language tests.
Change-Id: I8d92758c3a43ed0eff2e0c953ae8a87e65a3a920 Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/291047 Commit-Queue: Kallen Tu <kallentu@google.com> Reviewed-by: Leaf Petersen <leafp@google.com>
This commit is contained in:
parent
1ac8b374a2
commit
fd1b48d82e
|
@ -11,7 +11,9 @@ import 'package:expect/expect.dart';
|
|||
base class BaseClass {
|
||||
int foo = 0;
|
||||
}
|
||||
|
||||
base class A extends BaseClass {}
|
||||
|
||||
base class B implements BaseClass {
|
||||
int foo = 1;
|
||||
}
|
||||
|
@ -19,13 +21,18 @@ base class B implements BaseClass {
|
|||
base mixin BaseMixin {
|
||||
int foo = 0;
|
||||
}
|
||||
|
||||
base class AMixin with BaseMixin {}
|
||||
|
||||
base class BMixin = Object with BaseMixin;
|
||||
|
||||
// Used for trivial runtime tests of the base subtypes.
|
||||
base class AConcrete extends A {}
|
||||
|
||||
base class BConcrete extends B {}
|
||||
|
||||
base class AMixinConcrete extends AMixin {}
|
||||
|
||||
base class BMixinConcrete extends BMixin {}
|
||||
|
||||
main() {
|
||||
|
|
|
@ -12,49 +12,57 @@ import 'package:expect/expect.dart';
|
|||
base class BaseClass {
|
||||
int foo = 0;
|
||||
}
|
||||
|
||||
base mixin BaseMixin {
|
||||
int foo = 0;
|
||||
}
|
||||
|
||||
base class BaseExtends extends BaseClass {}
|
||||
|
||||
final class FinalExtends extends BaseClass {}
|
||||
|
||||
sealed class SealedExtends extends BaseClass {}
|
||||
|
||||
base class SealedExtendsImpl extends SealedExtends {}
|
||||
|
||||
base class BaseImplements implements BaseClass {
|
||||
int foo = 0;
|
||||
}
|
||||
|
||||
final class FinalImplements implements BaseClass {
|
||||
int foo = 0;
|
||||
}
|
||||
|
||||
sealed class SealedImplements implements BaseClass {
|
||||
int foo = 0;
|
||||
}
|
||||
|
||||
base class SealedImplementsImpl extends SealedImplements {}
|
||||
|
||||
base mixin BaseMixinImplements implements BaseMixin {}
|
||||
final mixin FinalMixinImplements implements BaseMixin {}
|
||||
sealed mixin SealedMixinImplements implements BaseMixin {}
|
||||
|
||||
base class ImplementsImpl implements BaseMixinImplements, FinalMixinImplements, SealedMixinImplements {
|
||||
base class ImplementsImpl implements BaseMixinImplements {
|
||||
int foo = 0;
|
||||
}
|
||||
|
||||
base class BaseWith with BaseMixin {}
|
||||
|
||||
final class FinalWith with BaseMixin {}
|
||||
|
||||
sealed class SealedWith with BaseMixin {}
|
||||
|
||||
base class SealedWithImpl extends SealedWith {}
|
||||
|
||||
base mixin BaseOn on BaseClass {}
|
||||
final mixin FinalOn on BaseClass {}
|
||||
sealed mixin SealedOn on BaseClass {}
|
||||
|
||||
base class OnImpl implements BaseOn, FinalOn, SealedOn {
|
||||
base class OnImpl implements BaseOn {
|
||||
int foo = 0;
|
||||
}
|
||||
|
||||
base mixin MixinForEnum {}
|
||||
|
||||
enum EnumWith with MixinForEnum { x }
|
||||
|
||||
enum EnumImplements implements MixinForEnum { x }
|
||||
|
||||
main() {
|
||||
|
|
|
@ -11,31 +11,19 @@ import 'package:expect/expect.dart';
|
|||
final class FinalClass {
|
||||
int foo = 0;
|
||||
}
|
||||
|
||||
final class A extends FinalClass {}
|
||||
|
||||
final class B implements FinalClass {
|
||||
int foo = 1;
|
||||
}
|
||||
|
||||
final mixin FinalMixin {
|
||||
int foo = 0;
|
||||
}
|
||||
final class C implements FinalMixin {
|
||||
int foo = 1;
|
||||
}
|
||||
final class AMixin with FinalMixin {}
|
||||
final class BMixin = Object with FinalMixin;
|
||||
|
||||
// Used for trivial runtime tests of the final subtypes.
|
||||
final class AConcrete extends A {}
|
||||
|
||||
final class BConcrete extends B {}
|
||||
final class CConcrete extends C {}
|
||||
final class AMixinConcrete extends AMixin {}
|
||||
final class BMixinConcrete extends BMixin {}
|
||||
|
||||
main() {
|
||||
Expect.equals(0, AConcrete().foo);
|
||||
Expect.equals(1, BConcrete().foo);
|
||||
Expect.equals(1, CConcrete().foo);
|
||||
Expect.equals(0, AMixinConcrete().foo);
|
||||
Expect.equals(0, BMixinConcrete().foo);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -9,16 +9,12 @@
|
|||
|
||||
final class FinalClass {}
|
||||
|
||||
final mixin FinalMixin {}
|
||||
|
||||
base class BaseClass extends FinalClass {}
|
||||
|
||||
sealed class SubtypeOfFinal extends FinalClass {}
|
||||
|
||||
class RegularClass {}
|
||||
|
||||
final mixin FinalMixin2 {}
|
||||
|
||||
class Extends extends FinalClass {}
|
||||
// ^^^^^^^
|
||||
// [analyzer] COMPILE_TIME_ERROR.SUBTYPE_OF_BASE_OR_FINAL_IS_NOT_BASE_FINAL_OR_SEALED
|
||||
|
@ -29,21 +25,6 @@ class Implements implements FinalClass {}
|
|||
// [analyzer] COMPILE_TIME_ERROR.SUBTYPE_OF_BASE_OR_FINAL_IS_NOT_BASE_FINAL_OR_SEALED
|
||||
// [cfe] The type 'Implements' must be 'base', 'final' or 'sealed' because the supertype 'FinalClass' is 'final'.
|
||||
|
||||
mixin MixinImplements implements FinalMixin {}
|
||||
// ^^^^^^^^^^^^^^^
|
||||
// [analyzer] COMPILE_TIME_ERROR.SUBTYPE_OF_BASE_OR_FINAL_IS_NOT_BASE_FINAL_OR_SEALED
|
||||
// [cfe] The type 'MixinImplements' must be 'base', 'final' or 'sealed' because the supertype 'FinalMixin' is 'final'.
|
||||
|
||||
class With with FinalMixin {}
|
||||
// ^^^^
|
||||
// [analyzer] COMPILE_TIME_ERROR.SUBTYPE_OF_BASE_OR_FINAL_IS_NOT_BASE_FINAL_OR_SEALED
|
||||
// [cfe] The type 'With' must be 'base', 'final' or 'sealed' because the supertype 'FinalMixin' is 'final'.
|
||||
|
||||
class With2 with FinalMixin, FinalMixin2 {}
|
||||
// ^^^^^
|
||||
// [analyzer] COMPILE_TIME_ERROR.SUBTYPE_OF_BASE_OR_FINAL_IS_NOT_BASE_FINAL_OR_SEALED
|
||||
// [cfe] The type 'With2' must be 'base', 'final' or 'sealed' because the supertype 'FinalMixin' is 'final'.
|
||||
|
||||
mixin On on FinalClass {}
|
||||
// ^^
|
||||
// [analyzer] COMPILE_TIME_ERROR.SUBTYPE_OF_BASE_OR_FINAL_IS_NOT_BASE_FINAL_OR_SEALED
|
||||
|
@ -53,15 +34,10 @@ class ExtendsExtends extends Extends {}
|
|||
// ^
|
||||
// [cfe] The type 'ExtendsExtends' must be 'base', 'final' or 'sealed' because the supertype 'FinalClass' is 'final'.
|
||||
|
||||
class Multiple extends BaseClass implements FinalMixin {}
|
||||
class Multiple extends RegularClass implements FinalClass {}
|
||||
// ^^^^^^^^
|
||||
// [analyzer] COMPILE_TIME_ERROR.SUBTYPE_OF_BASE_OR_FINAL_IS_NOT_BASE_FINAL_OR_SEALED
|
||||
// [cfe] The type 'Multiple' must be 'base', 'final' or 'sealed' because the supertype 'BaseClass' is 'base'.
|
||||
|
||||
class Multiple2 extends RegularClass implements FinalClass {}
|
||||
// ^^^^^^^^^
|
||||
// [analyzer] COMPILE_TIME_ERROR.SUBTYPE_OF_BASE_OR_FINAL_IS_NOT_BASE_FINAL_OR_SEALED
|
||||
// [cfe] The type 'Multiple2' must be 'base', 'final' or 'sealed' because the supertype 'FinalClass' is 'final'.
|
||||
// [cfe] The type 'Multiple' must be 'base', 'final' or 'sealed' because the supertype 'FinalClass' is 'final'.
|
||||
|
||||
class IndirectSubtype extends SubtypeOfFinal {}
|
||||
// ^^^^^^^^^^^^^^^
|
||||
|
|
|
@ -12,49 +12,39 @@ import 'package:expect/expect.dart';
|
|||
final class FinalClass {
|
||||
int foo = 0;
|
||||
}
|
||||
final mixin FinalMixin {
|
||||
int foo = 0;
|
||||
}
|
||||
|
||||
base class BaseExtends extends FinalClass {}
|
||||
|
||||
final class FinalExtends extends FinalClass {}
|
||||
|
||||
sealed class SealedExtends extends FinalClass {}
|
||||
|
||||
final class SealedExtendsImpl extends SealedExtends {}
|
||||
|
||||
base class BaseImplements implements FinalClass {
|
||||
int foo = 0;
|
||||
}
|
||||
|
||||
final class FinalImplements implements FinalClass {
|
||||
int foo = 0;
|
||||
}
|
||||
|
||||
sealed class SealedImplements implements FinalClass {
|
||||
int foo = 0;
|
||||
}
|
||||
|
||||
final class SealedImplementsImpl extends SealedImplements {}
|
||||
|
||||
base mixin BaseMixinImplements implements FinalMixin {}
|
||||
final mixin FinalMixinImplements implements FinalMixin {}
|
||||
sealed mixin SealedMixinImplements implements FinalMixin {}
|
||||
|
||||
final class ImplementsImpl implements BaseMixinImplements, FinalMixinImplements, SealedMixinImplements {
|
||||
int foo = 0;
|
||||
}
|
||||
|
||||
base class BaseWith with FinalMixin {}
|
||||
final class FinalWith with FinalMixin {}
|
||||
sealed class SealedWith with FinalMixin {}
|
||||
final class SealedWithImpl extends SealedWith {}
|
||||
|
||||
base mixin BaseOn on FinalClass {}
|
||||
final mixin FinalOn on FinalClass {}
|
||||
sealed mixin SealedOn on FinalClass {}
|
||||
|
||||
final class OnImpl implements BaseOn, FinalOn, SealedOn {
|
||||
final class OnImpl implements BaseOn {
|
||||
int foo = 0;
|
||||
}
|
||||
|
||||
base mixin MixinForEnum {}
|
||||
|
||||
enum EnumWith with MixinForEnum { x }
|
||||
|
||||
enum EnumImplements implements MixinForEnum { x }
|
||||
|
||||
main() {
|
||||
|
@ -64,10 +54,6 @@ main() {
|
|||
Expect.equals(0, BaseImplements().foo);
|
||||
Expect.equals(0, FinalImplements().foo);
|
||||
Expect.equals(0, SealedImplementsImpl().foo);
|
||||
Expect.equals(0, ImplementsImpl().foo);
|
||||
Expect.equals(0, BaseWith().foo);
|
||||
Expect.equals(0, FinalWith().foo);
|
||||
Expect.equals(0, SealedWithImpl().foo);
|
||||
Expect.equals(0, OnImpl().foo);
|
||||
Expect.equals(0, EnumWith.x.index);
|
||||
Expect.equals(0, EnumImplements.x.index);
|
||||
|
|
|
@ -1,25 +0,0 @@
|
|||
// 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=class-modifiers
|
||||
|
||||
// Allow final mixins to be implemented by multiple classes in the same library.
|
||||
|
||||
final mixin FinalMixin {
|
||||
int foo = 0;
|
||||
}
|
||||
|
||||
final mixin MixinForEnum {}
|
||||
|
||||
abstract final class A implements FinalMixin {}
|
||||
|
||||
final class AImpl implements A {
|
||||
int foo = 1;
|
||||
}
|
||||
|
||||
final class B implements FinalMixin {
|
||||
int foo = 1;
|
||||
}
|
||||
|
||||
enum EnumInside implements MixinForEnum { x }
|
|
@ -1,26 +0,0 @@
|
|||
// 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=class-modifiers
|
||||
|
||||
// Error when attempting to implement final mixin outside of library.
|
||||
|
||||
import 'final_mixin_implement_lib.dart';
|
||||
|
||||
abstract final class AOutside implements FinalMixin {}
|
||||
// ^^^^^^^^^^
|
||||
// [analyzer] COMPILE_TIME_ERROR.INVALID_USE_OF_TYPE_OUTSIDE_LIBRARY
|
||||
// [cfe] The mixin 'FinalMixin' can't be implemented outside of its library because it's a final mixin.
|
||||
|
||||
final class BOutside implements FinalMixin {
|
||||
// ^^^^^^^^^^
|
||||
// [analyzer] COMPILE_TIME_ERROR.INVALID_USE_OF_TYPE_OUTSIDE_LIBRARY
|
||||
// [cfe] The mixin 'FinalMixin' can't be implemented outside of its library because it's a final mixin.
|
||||
int foo = 1;
|
||||
}
|
||||
|
||||
enum EnumOutside implements MixinForEnum { x }
|
||||
// ^^^^^^^^^^^^
|
||||
// [analyzer] COMPILE_TIME_ERROR.INVALID_USE_OF_TYPE_OUTSIDE_LIBRARY
|
||||
// [cfe] The mixin 'MixinForEnum' can't be implemented outside of its library because it's a final mixin.
|
|
@ -1,16 +0,0 @@
|
|||
// 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=class-modifiers
|
||||
|
||||
// Allow final mixins to be implemented by multiple classes in the same library.
|
||||
|
||||
import 'package:expect/expect.dart';
|
||||
import 'final_mixin_implement_lib.dart';
|
||||
|
||||
main() {
|
||||
Expect.equals(1, AImpl().foo);
|
||||
Expect.equals(1, B().foo);
|
||||
Expect.equals(0, EnumInside.x.index);
|
||||
}
|
|
@ -1,18 +0,0 @@
|
|||
// 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=class-modifiers
|
||||
|
||||
// Other-library declarations used by
|
||||
// final_mixin_typedef_with_outside_error_test.dart.
|
||||
|
||||
final mixin FinalMixin {
|
||||
int foo = 0;
|
||||
}
|
||||
|
||||
typedef FinalMixinTypeDef = FinalMixin;
|
||||
|
||||
final class A with FinalMixinTypeDef {
|
||||
int foo = 1;
|
||||
}
|
|
@ -1,19 +0,0 @@
|
|||
// 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=class-modifiers
|
||||
|
||||
// Error when attempting to mix in a typedef final mixin outside of library.
|
||||
|
||||
import 'final_mixin_typedef_with_lib.dart';
|
||||
|
||||
abstract final class AOutside with FinalMixinTypeDef {}
|
||||
// ^^^^^^^^^^^^^^^^^
|
||||
// [analyzer] COMPILE_TIME_ERROR.INVALID_USE_OF_TYPE_OUTSIDE_LIBRARY
|
||||
// [cfe] The mixin 'FinalMixin' can't be mixed-in outside of its library because it's a final mixin.
|
||||
|
||||
final class BOutside with FinalMixinTypeDef {}
|
||||
// ^^^^^^^^^^^^^^^^^
|
||||
// [analyzer] COMPILE_TIME_ERROR.INVALID_USE_OF_TYPE_OUTSIDE_LIBRARY
|
||||
// [cfe] The mixin 'FinalMixin' can't be mixed-in outside of its library because it's a final mixin.
|
|
@ -1,15 +0,0 @@
|
|||
// 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=class-modifiers
|
||||
|
||||
// Allow typedef final mixins to be mixed in by multiple classes in the same
|
||||
// library.
|
||||
|
||||
import 'package:expect/expect.dart';
|
||||
import 'final_mixin_typedef_with_lib.dart';
|
||||
|
||||
main() {
|
||||
Expect.equals(1, A().foo);
|
||||
}
|
|
@ -1,21 +0,0 @@
|
|||
// 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=class-modifiers
|
||||
|
||||
// Allow final mixins to be mixed by multiple classes in the same library.
|
||||
|
||||
final mixin FinalMixin {
|
||||
int foo = 0;
|
||||
}
|
||||
|
||||
final mixin MixinForEnum {}
|
||||
|
||||
abstract final class A with FinalMixin {}
|
||||
|
||||
final class AImpl extends A {}
|
||||
|
||||
final class B with FinalMixin {}
|
||||
|
||||
enum EnumInside with MixinForEnum { x }
|
|
@ -1,24 +0,0 @@
|
|||
// 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=class-modifiers
|
||||
|
||||
// Error when attempting to mix in final mixin outside of library.
|
||||
|
||||
import 'final_mixin_with_lib.dart';
|
||||
|
||||
abstract final class AOutside with FinalMixin {}
|
||||
// ^^^^^^^^^^
|
||||
// [analyzer] COMPILE_TIME_ERROR.INVALID_USE_OF_TYPE_OUTSIDE_LIBRARY
|
||||
// [cfe] The mixin 'FinalMixin' can't be mixed-in outside of its library because it's a final mixin.
|
||||
|
||||
final class BOutside with FinalMixin {}
|
||||
// ^^^^^^^^^^
|
||||
// [analyzer] COMPILE_TIME_ERROR.INVALID_USE_OF_TYPE_OUTSIDE_LIBRARY
|
||||
// [cfe] The mixin 'FinalMixin' can't be mixed-in outside of its library because it's a final mixin.
|
||||
|
||||
enum EnumOutside with MixinForEnum { x }
|
||||
// ^^^^^^^^^^^^
|
||||
// [analyzer] COMPILE_TIME_ERROR.INVALID_USE_OF_TYPE_OUTSIDE_LIBRARY
|
||||
// [cfe] The mixin 'MixinForEnum' can't be mixed-in outside of its library because it's a final mixin.
|
|
@ -1,16 +0,0 @@
|
|||
// 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=class-modifiers
|
||||
|
||||
// Allow final mixins to be mixed by multiple classes in the same library.
|
||||
|
||||
import 'package:expect/expect.dart';
|
||||
import 'final_mixin_with_lib.dart';
|
||||
|
||||
main() {
|
||||
Expect.equals(0, AImpl().foo);
|
||||
Expect.equals(0, B().foo);
|
||||
Expect.equals(0, EnumInside.x.index);
|
||||
}
|
|
@ -11,26 +11,19 @@ import 'package:expect/expect.dart';
|
|||
interface class InterfaceClass {
|
||||
int foo = 0;
|
||||
}
|
||||
|
||||
interface class A extends InterfaceClass {}
|
||||
|
||||
interface class B implements InterfaceClass {
|
||||
int foo = 1;
|
||||
}
|
||||
|
||||
interface mixin InterfaceMixin {
|
||||
int foo = 0;
|
||||
}
|
||||
interface class AMixin with InterfaceMixin {}
|
||||
interface class BMixin = Object with InterfaceMixin;
|
||||
|
||||
// Used for trivial runtime tests of the interface subtypes.
|
||||
class AConcrete extends A {}
|
||||
|
||||
class BConcrete extends B {}
|
||||
class AMixinConcrete extends AMixin {}
|
||||
class BMixinConcrete extends BMixin {}
|
||||
|
||||
main() {
|
||||
Expect.equals(0, AConcrete().foo);
|
||||
Expect.equals(1, BConcrete().foo);
|
||||
Expect.equals(0, AMixinConcrete().foo);
|
||||
Expect.equals(0, BMixinConcrete().foo);
|
||||
}
|
||||
|
|
|
@ -11,9 +11,3 @@ interface class InterfaceClass {}
|
|||
abstract class A extends InterfaceClass {}
|
||||
|
||||
class B extends InterfaceClass {}
|
||||
|
||||
interface mixin InterfaceMixin {}
|
||||
|
||||
class C extends InterfaceClass with InterfaceMixin {}
|
||||
|
||||
class D with InterfaceMixin {}
|
||||
|
|
|
@ -17,20 +17,6 @@ class ConcreteA extends A with MA, MB {
|
|||
int foo = 0;
|
||||
}
|
||||
|
||||
mixin MC on InterfaceClass, InterfaceMixin {}
|
||||
|
||||
class ConcreteC extends C with MC {
|
||||
int foo = 0;
|
||||
}
|
||||
|
||||
mixin MCSingular on InterfaceMixin {}
|
||||
|
||||
class ConcreteD extends D with MCSingular {
|
||||
int foo = 0;
|
||||
}
|
||||
|
||||
main() {
|
||||
Expect.equals(0, ConcreteA().foo);
|
||||
Expect.equals(0, ConcreteC().foo);
|
||||
Expect.equals(0, ConcreteD().foo);
|
||||
}
|
||||
|
|
|
@ -1,20 +0,0 @@
|
|||
// 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=class-modifiers
|
||||
|
||||
// Allow interface mixins to be implemented by multiple classes in the same
|
||||
// library.
|
||||
|
||||
interface mixin InterfaceMixin {
|
||||
int foo = 0;
|
||||
}
|
||||
|
||||
interface mixin MixinForEnum {}
|
||||
|
||||
abstract class A implements InterfaceMixin {}
|
||||
|
||||
class B implements InterfaceMixin {
|
||||
int foo = 1;
|
||||
}
|
|
@ -1,29 +0,0 @@
|
|||
// 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=class-modifiers
|
||||
|
||||
// Allow interface mixins to be implemented by multiple classes outside its
|
||||
// library.
|
||||
|
||||
import 'package:expect/expect.dart';
|
||||
import 'interface_mixin_implement_lib.dart';
|
||||
|
||||
abstract class AOutside implements InterfaceMixin {}
|
||||
|
||||
class AOutsideImpl implements AOutside {
|
||||
int foo = 1;
|
||||
}
|
||||
|
||||
class BOutside implements InterfaceMixin {
|
||||
int foo = 1;
|
||||
}
|
||||
|
||||
enum EnumOutside implements MixinForEnum { x }
|
||||
|
||||
main() {
|
||||
Expect.equals(1, AOutsideImpl().foo);
|
||||
Expect.equals(1, BOutside().foo);
|
||||
Expect.equals(0, EnumOutside.x.index);
|
||||
}
|
|
@ -1,19 +0,0 @@
|
|||
// 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=class-modifiers
|
||||
|
||||
// Other-library declarations used by
|
||||
// interface_mixin_typedef_with_outside_error_test.dart and
|
||||
// interface_mixin_typedef_with_test.dart.
|
||||
|
||||
interface mixin InterfaceMixin {
|
||||
int foo = 0;
|
||||
}
|
||||
|
||||
typedef InterfaceMixinTypeDef = InterfaceMixin;
|
||||
|
||||
class A with InterfaceMixinTypeDef {
|
||||
int foo = 1;
|
||||
}
|
|
@ -1,19 +0,0 @@
|
|||
// 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=class-modifiers
|
||||
|
||||
// Error when attempting to mix in a typedef interface mixin outside of library.
|
||||
|
||||
import 'interface_mixin_typedef_with_lib.dart';
|
||||
|
||||
abstract class AOutside with InterfaceMixinTypeDef {}
|
||||
// ^^^^^^^^^^^^^^^^^^^^^
|
||||
// [analyzer] COMPILE_TIME_ERROR.INVALID_USE_OF_TYPE_OUTSIDE_LIBRARY
|
||||
// [cfe] The mixin 'InterfaceMixin' can't be mixed-in outside of its library because it's an interface mixin.
|
||||
|
||||
class BOutside with InterfaceMixinTypeDef {}
|
||||
// ^^^^^^^^^^^^^^^^^^^^^
|
||||
// [analyzer] COMPILE_TIME_ERROR.INVALID_USE_OF_TYPE_OUTSIDE_LIBRARY
|
||||
// [cfe] The mixin 'InterfaceMixin' can't be mixed-in outside of its library because it's an interface mixin.
|
|
@ -1,15 +0,0 @@
|
|||
// 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=class-modifiers
|
||||
|
||||
// Allow typedef interface mixins to be mixed in by multiple classes in the same
|
||||
// library.
|
||||
|
||||
import 'package:expect/expect.dart';
|
||||
import 'interface_mixin_typedef_with_lib.dart';
|
||||
|
||||
main() {
|
||||
Expect.equals(1, A().foo);
|
||||
}
|
|
@ -1,19 +0,0 @@
|
|||
// 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=class-modifiers
|
||||
|
||||
// Allow interface mixins to be mixed by multiple classes in the same library.
|
||||
|
||||
interface mixin InterfaceMixin {
|
||||
int foo = 0;
|
||||
}
|
||||
|
||||
interface mixin MixinForEnum {}
|
||||
|
||||
abstract class A with InterfaceMixin {}
|
||||
|
||||
class B with InterfaceMixin {}
|
||||
|
||||
enum EnumInside implements MixinForEnum { x }
|
|
@ -1,24 +0,0 @@
|
|||
// 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=class-modifiers
|
||||
|
||||
// Error when attempting to mix in interface mixin outside of library.
|
||||
|
||||
import 'interface_mixin_with_lib.dart';
|
||||
|
||||
abstract class AOutside with InterfaceMixin {}
|
||||
// ^^^^^^^^^^^^^^
|
||||
// [analyzer] COMPILE_TIME_ERROR.INVALID_USE_OF_TYPE_OUTSIDE_LIBRARY
|
||||
// [cfe] The mixin 'InterfaceMixin' can't be mixed-in outside of its library because it's an interface mixin.
|
||||
|
||||
class BOutside with InterfaceMixin {}
|
||||
// ^^^^^^^^^^^^^^
|
||||
// [analyzer] COMPILE_TIME_ERROR.INVALID_USE_OF_TYPE_OUTSIDE_LIBRARY
|
||||
// [cfe] The mixin 'InterfaceMixin' can't be mixed-in outside of its library because it's an interface mixin.
|
||||
|
||||
enum EnumOutside with MixinForEnum { x }
|
||||
// ^^^^^^^^^^^^
|
||||
// [analyzer] COMPILE_TIME_ERROR.INVALID_USE_OF_TYPE_OUTSIDE_LIBRARY
|
||||
// [cfe] The mixin 'MixinForEnum' can't be mixed-in outside of its library because it's an interface mixin.
|
|
@ -1,18 +0,0 @@
|
|||
// 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=class-modifiers
|
||||
|
||||
// Allow interface mixins to be mixed by multiple classes in the same library.
|
||||
|
||||
import 'package:expect/expect.dart';
|
||||
import 'interface_mixin_with_lib.dart';
|
||||
|
||||
class AImpl extends A {}
|
||||
|
||||
main() {
|
||||
Expect.equals(0, AImpl().foo);
|
||||
Expect.equals(0, B().foo);
|
||||
Expect.equals(0, EnumInside.x.index);
|
||||
}
|
|
@ -18,8 +18,3 @@ final class FinalClassTypeAlias = Object with M;
|
|||
// [error column 1, length 5]
|
||||
// [analyzer] SYNTACTIC_ERROR.EXPERIMENT_NOT_ENABLED
|
||||
// [cfe] The 'class-modifiers' language feature is disabled for this library.
|
||||
|
||||
final mixin FinalMixin {}
|
||||
// [error column 1, length 5]
|
||||
// [analyzer] SYNTACTIC_ERROR.EXPERIMENT_NOT_ENABLED
|
||||
// [cfe] The 'class-modifiers' language feature is disabled for this library.
|
||||
|
|
|
@ -18,8 +18,3 @@ interface class InterfaceClassTypeAlias = Object with M;
|
|||
// [error column 1, length 9]
|
||||
// [analyzer] SYNTACTIC_ERROR.EXPERIMENT_NOT_ENABLED
|
||||
// [cfe] The 'class-modifiers' language feature is disabled for this library.
|
||||
|
||||
interface mixin InterfaceMixin {}
|
||||
// [error column 1, length 9]
|
||||
// [analyzer] SYNTACTIC_ERROR.EXPERIMENT_NOT_ENABLED
|
||||
// [cfe] The 'class-modifiers' language feature is disabled for this library.
|
||||
|
|
|
@ -42,15 +42,7 @@ abstract class OutsideD with SealedClass, Class {}
|
|||
// [analyzer] COMPILE_TIME_ERROR.CLASS_USED_AS_MIXIN
|
||||
// [cfe] The class 'Class' can't be used as a mixin because it isn't a mixin class nor a mixin.
|
||||
|
||||
class OutsideE with Class, SealedMixin {}
|
||||
// ^^^^^
|
||||
// [analyzer] COMPILE_TIME_ERROR.CLASS_USED_AS_MIXIN
|
||||
// [cfe] The class 'Class' can't be used as a mixin because it isn't a mixin class nor a mixin.
|
||||
// ^^^^^^^^^^^
|
||||
// [analyzer] COMPILE_TIME_ERROR.INVALID_USE_OF_TYPE_OUTSIDE_LIBRARY
|
||||
// [cfe] The mixin 'SealedMixin' can't be mixed in outside of its library because it's a sealed mixin.
|
||||
|
||||
abstract class OutsideF with Mixin, SealedClass {}
|
||||
abstract class OutsideE with Mixin, SealedClass {}
|
||||
// ^^^^^^^^^^^
|
||||
// [analyzer] COMPILE_TIME_ERROR.CLASS_USED_AS_MIXIN
|
||||
// [analyzer] COMPILE_TIME_ERROR.INVALID_USE_OF_TYPE_OUTSIDE_LIBRARY
|
||||
|
|
|
@ -12,6 +12,7 @@ sealed class SealedClass {
|
|||
int nonAbstractBar(int value) => value + 100;
|
||||
int bar(int value);
|
||||
}
|
||||
sealed mixin SealedMixin {}
|
||||
|
||||
class Class {}
|
||||
|
||||
mixin Mixin {}
|
||||
|
|
|
@ -9,8 +9,6 @@
|
|||
|
||||
sealed class NotConstructable {}
|
||||
|
||||
sealed mixin AlsoNotConstructable {}
|
||||
|
||||
mixin M {}
|
||||
sealed class NotConstructableWithMixin = Object with M;
|
||||
|
||||
|
@ -19,10 +17,6 @@ main() {
|
|||
// ^^^^^^^^^^^^^^^^
|
||||
// [analyzer] COMPILE_TIME_ERROR.INSTANTIATE_ABSTRACT_CLASS
|
||||
// [cfe] The class 'NotConstructable' is abstract and can't be instantiated.
|
||||
var error2 = AlsoNotConstructable();
|
||||
// ^^^^^^^^^^^^^^^^^^^^
|
||||
// [analyzer] COMPILE_TIME_ERROR.MIXIN_INSTANTIATE
|
||||
// [cfe] Couldn't find constructor 'AlsoNotConstructable'.
|
||||
var error3 = NotConstructableWithMixin();
|
||||
// ^^^^^^^^^^^^^^^^^^^^^^^^^
|
||||
// [analyzer] COMPILE_TIME_ERROR.INSTANTIATE_ABSTRACT_CLASS
|
||||
|
|
|
@ -10,23 +10,18 @@ import "package:expect/expect.dart";
|
|||
sealed class SealedClass {
|
||||
int foo = 0;
|
||||
}
|
||||
|
||||
sealed class A extends SealedClass {}
|
||||
|
||||
sealed class B implements SealedClass {
|
||||
@override
|
||||
int foo = 1;
|
||||
}
|
||||
|
||||
sealed mixin SealedMixin {
|
||||
int foo = 0;
|
||||
}
|
||||
sealed class AMixin with SealedMixin {}
|
||||
sealed class BMixin = Object with SealedMixin;
|
||||
|
||||
// Used for trivial runtime tests of the sealed subtypes.
|
||||
class AConcrete extends A {}
|
||||
|
||||
class BConcrete extends B {}
|
||||
class AMixinConcrete extends AMixin {}
|
||||
class BMixinConcrete extends BMixin {}
|
||||
|
||||
main() {
|
||||
var a = AConcrete();
|
||||
|
@ -34,10 +29,4 @@ main() {
|
|||
|
||||
var b = BConcrete();
|
||||
Expect.equals(1, b.foo);
|
||||
|
||||
var amixin = AMixinConcrete();
|
||||
Expect.equals(0, amixin.foo);
|
||||
|
||||
var bmixin = BMixinConcrete();
|
||||
Expect.equals(0, bmixin.foo);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -29,8 +29,3 @@ sealed class SealedClassTypeAlias = Object with M;
|
|||
// [error column 1, length 6]
|
||||
// [analyzer] SYNTACTIC_ERROR.EXPERIMENT_NOT_ENABLED
|
||||
// [cfe] The 'sealed-class' language feature is disabled for this library.
|
||||
|
||||
sealed mixin SealedMixin {}
|
||||
// [error column 1, length 6]
|
||||
// [analyzer] SYNTACTIC_ERROR.EXPERIMENT_NOT_ENABLED
|
||||
// [cfe] The 'sealed-class' language feature is disabled for this library.
|
||||
|
|
|
@ -1,14 +0,0 @@
|
|||
// 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
|
||||
|
||||
// Error when attempting to mix in a typedef sealed mixin outside of its library
|
||||
|
||||
import 'sealed_mixin_typedef_lib.dart';
|
||||
|
||||
class ATypeDef with SealedMixinTypeDef {}
|
||||
// ^^^^^^^^^^^^^^^^^^
|
||||
// [analyzer] COMPILE_TIME_ERROR.INVALID_USE_OF_TYPE_OUTSIDE_LIBRARY
|
||||
// [cfe] The mixin 'SealedMixin' can't be mixed in outside of its library because it's a sealed mixin.
|
|
@ -1,15 +0,0 @@
|
|||
// 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
|
||||
|
||||
// Other-library declarations used by sealed_mixin_typedef_test.dart.
|
||||
|
||||
sealed mixin SealedMixin {
|
||||
int foo = 0;
|
||||
}
|
||||
|
||||
typedef SealedMixinTypeDef = SealedMixin;
|
||||
|
||||
class A with SealedMixinTypeDef {}
|
|
@ -1,15 +0,0 @@
|
|||
// 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 typedef sealed mixins to be mixed in by classes in the same library.
|
||||
|
||||
import "package:expect/expect.dart";
|
||||
import 'sealed_mixin_typedef_lib.dart';
|
||||
|
||||
main() {
|
||||
var a = A();
|
||||
Expect.equals(0, a.foo);
|
||||
}
|
|
@ -1,32 +0,0 @@
|
|||
// 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
|
||||
|
||||
// Error when attempting to mix in a sealed mixin outside of its library.
|
||||
|
||||
import 'sealed_mixin_with_lib.dart';
|
||||
|
||||
abstract class OutsideA with SealedMixin {}
|
||||
// ^^^^^^^^^^^
|
||||
// [analyzer] COMPILE_TIME_ERROR.INVALID_USE_OF_TYPE_OUTSIDE_LIBRARY
|
||||
// [cfe] The mixin 'SealedMixin' can't be mixed in outside of its library because it's a sealed mixin.
|
||||
|
||||
class OutsideB with SealedMixin {
|
||||
// ^^^^^^^^^^^
|
||||
// [analyzer] COMPILE_TIME_ERROR.INVALID_USE_OF_TYPE_OUTSIDE_LIBRARY
|
||||
// [cfe] The mixin 'SealedMixin' can't be mixed in outside of its library because it's a sealed mixin.
|
||||
int foo = 2;
|
||||
int bar(int value) => value;
|
||||
}
|
||||
|
||||
abstract class OutsideC = Object with SealedMixin;
|
||||
// ^^^^^^^^^^^
|
||||
// [analyzer] COMPILE_TIME_ERROR.INVALID_USE_OF_TYPE_OUTSIDE_LIBRARY
|
||||
// [cfe] The mixin 'SealedMixin' can't be mixed in outside of its library because it's a sealed mixin.
|
||||
|
||||
enum EnumOutside with MixinForEnum { x }
|
||||
// ^^^^^^^^^^^^
|
||||
// [analyzer] COMPILE_TIME_ERROR.INVALID_USE_OF_TYPE_OUTSIDE_LIBRARY
|
||||
// [cfe] The mixin 'MixinForEnum' can't be mixed in outside of its library because it's a sealed mixin.
|
|
@ -1,39 +0,0 @@
|
|||
// 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
|
||||
|
||||
// Other-library declarations used by sealed_mixin_with_error_test.dart and
|
||||
// sealed_mixin_with_test.dart.
|
||||
|
||||
sealed mixin SealedMixin {
|
||||
int nonAbstractFoo = 0;
|
||||
abstract int foo;
|
||||
int nonAbstractBar(int value) => value + 100;
|
||||
int bar(int value);
|
||||
}
|
||||
|
||||
sealed mixin MixinForEnum {}
|
||||
|
||||
abstract class A with SealedMixin {}
|
||||
|
||||
class AImpl extends A {
|
||||
int foo = 1;
|
||||
int bar(int value) => value + 1;
|
||||
}
|
||||
|
||||
class B with SealedMixin {
|
||||
int nonAbstractFoo = 100;
|
||||
int foo = 2;
|
||||
int bar(int value) => value;
|
||||
}
|
||||
|
||||
abstract class C = Object with SealedMixin;
|
||||
|
||||
class CImpl extends C {
|
||||
int foo = 3;
|
||||
int bar(int value) => value - 1;
|
||||
}
|
||||
|
||||
enum EnumInside with MixinForEnum { x }
|
|
@ -1,57 +0,0 @@
|
|||
// 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 sealed mixins to be mixed in by multiple classes in the same library.
|
||||
// Additionally, allow their subclasses/subtypes to be used freely.
|
||||
|
||||
import "package:expect/expect.dart";
|
||||
import 'sealed_mixin_with_lib.dart';
|
||||
|
||||
class AExtends extends A {
|
||||
int foo = 0;
|
||||
int bar(int value) => value;
|
||||
}
|
||||
|
||||
class AImplements implements A {
|
||||
int nonAbstractFoo = 0;
|
||||
int foo = 0;
|
||||
int bar(int value) => value;
|
||||
int nonAbstractBar(int value) => value;
|
||||
}
|
||||
|
||||
main() {
|
||||
A a = AImpl();
|
||||
Expect.equals(0, a.nonAbstractFoo);
|
||||
Expect.equals(1, a.foo);
|
||||
Expect.equals(3, a.bar(2));
|
||||
Expect.equals(100, a.nonAbstractBar(0));
|
||||
|
||||
var b = B();
|
||||
Expect.equals(100, b.nonAbstractFoo);
|
||||
Expect.equals(2, b.foo);
|
||||
Expect.equals(2, b.bar(2));
|
||||
Expect.equals(100, b.nonAbstractBar(0));
|
||||
|
||||
C c = CImpl();
|
||||
Expect.equals(0, c.nonAbstractFoo);
|
||||
Expect.equals(3, c.foo);
|
||||
Expect.equals(1, c.bar(2));
|
||||
Expect.equals(100, c.nonAbstractBar(0));
|
||||
|
||||
var aExtends = AExtends();
|
||||
Expect.equals(0, aExtends.nonAbstractFoo);
|
||||
Expect.equals(0, aExtends.foo);
|
||||
Expect.equals(0, aExtends.bar(0));
|
||||
Expect.equals(100, aExtends.nonAbstractBar(0));
|
||||
|
||||
var aImplements = AImplements();
|
||||
Expect.equals(0, aImplements.nonAbstractFoo);
|
||||
Expect.equals(0, aImplements.foo);
|
||||
Expect.equals(0, aImplements.bar(0));
|
||||
Expect.equals(0, aImplements.nonAbstractBar(0));
|
||||
|
||||
Expect.equals(0, EnumInside.x.index);
|
||||
}
|
Loading…
Reference in a new issue