[tests] Update language tests with base/final subtyping loophole fixed and a few enum tests.
Change-Id: Id30bbdc4b6eedf0751f725024acbed812a07a4fc Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/280860 Commit-Queue: Kallen Tu <kallentu@google.com> Reviewed-by: Lasse Nielsen <lrn@google.com>
This commit is contained in:
@@ -13,11 +13,11 @@ abstract base class AlsoNotConstructable = Object with M;
|
||||
|
||||
main() {
|
||||
var error = NotConstructable();
|
||||
// ^
|
||||
// [analyzer] unspecified
|
||||
// [cfe] unspecified
|
||||
// ^^^^^^^^^^^^^^^^
|
||||
// [analyzer] COMPILE_TIME_ERROR.INSTANTIATE_ABSTRACT_CLASS
|
||||
// [cfe] The class 'NotConstructable' is abstract and can't be instantiated.
|
||||
var error2 = AlsoNotConstructable();
|
||||
// ^
|
||||
// [analyzer] unspecified
|
||||
// [cfe] unspecified
|
||||
// ^^^^^^^^^^^^^^^^^^^^
|
||||
// [analyzer] COMPILE_TIME_ERROR.INSTANTIATE_ABSTRACT_CLASS
|
||||
// [cfe] The class 'AlsoNotConstructable' is abstract and can't be instantiated.
|
||||
}
|
||||
|
||||
@@ -13,7 +13,6 @@ base class BaseClass {
|
||||
}
|
||||
base class A extends BaseClass {}
|
||||
base class B implements BaseClass {
|
||||
@override
|
||||
int foo = 1;
|
||||
}
|
||||
|
||||
@@ -24,14 +23,14 @@ base class AMixin with BaseMixin {}
|
||||
base class BMixin = Object with BaseMixin;
|
||||
|
||||
// Used for trivial runtime tests of the base subtypes.
|
||||
class AConcrete extends A {}
|
||||
class BConcrete extends B {}
|
||||
class AMixinConcrete extends AMixin {}
|
||||
class BMixinConcrete extends BMixin {}
|
||||
base class AConcrete extends A {}
|
||||
base class BConcrete extends B {}
|
||||
base class AMixinConcrete extends AMixin {}
|
||||
base 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);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -10,6 +10,6 @@ base class BaseClass {
|
||||
int foo = 0;
|
||||
}
|
||||
|
||||
abstract class A extends BaseClass {}
|
||||
abstract base class A extends BaseClass {}
|
||||
|
||||
class B extends BaseClass {}
|
||||
base class B extends BaseClass {}
|
||||
|
||||
+2
-2
@@ -4,8 +4,8 @@
|
||||
|
||||
// SharedOptions=--enable-experiment=class-modifiers
|
||||
|
||||
// Error when extending a base class where the subclass is not also a base class
|
||||
// or final.
|
||||
// Error when extending a base class where the subclass is not a base, final or
|
||||
// sealed class.
|
||||
|
||||
import 'base_class_extend_lib.dart';
|
||||
|
||||
|
||||
@@ -10,7 +10,7 @@
|
||||
import 'package:expect/expect.dart';
|
||||
import 'base_class_extend_lib.dart';
|
||||
|
||||
class AImpl extends A {}
|
||||
base class AImpl extends A {}
|
||||
|
||||
main() {
|
||||
Expect.equals(0, AImpl().foo);
|
||||
|
||||
@@ -8,15 +8,19 @@
|
||||
|
||||
import 'base_class_implement_lib.dart';
|
||||
|
||||
abstract class AOutside implements BaseClass {}
|
||||
// ^^^^^^^^^
|
||||
abstract base class AOutside implements BaseClass {}
|
||||
// ^^^^^^^^^
|
||||
// [analyzer] COMPILE_TIME_ERROR.INVALID_USE_OF_TYPE_OUTSIDE_LIBRARY
|
||||
// [cfe] The class 'BaseClass' can't be implemented outside of its library because it's a base class.
|
||||
|
||||
class BOutside implements BaseClass {
|
||||
// ^^^^^^^^^
|
||||
base class BOutside implements BaseClass {
|
||||
// ^^^^^^^^^
|
||||
// [analyzer] COMPILE_TIME_ERROR.INVALID_USE_OF_TYPE_OUTSIDE_LIBRARY
|
||||
// [cfe] The class 'BaseClass' can't be implemented outside of its library because it's a base class.
|
||||
@override
|
||||
int foo = 1;
|
||||
}
|
||||
|
||||
enum EnumOutside implements ClassForEnum { x }
|
||||
// ^^^^^^^^^^^^
|
||||
// [analyzer] COMPILE_TIME_ERROR.INVALID_USE_OF_TYPE_OUTSIDE_LIBRARY
|
||||
// [cfe] The class 'ClassForEnum' can't be implemented outside of its library because it's a base class.
|
||||
|
||||
@@ -10,9 +10,16 @@ base class BaseClass {
|
||||
int foo = 0;
|
||||
}
|
||||
|
||||
abstract class A implements BaseClass {}
|
||||
base class ClassForEnum {}
|
||||
|
||||
class B implements BaseClass {
|
||||
@override
|
||||
abstract base class A implements BaseClass {}
|
||||
|
||||
base class AImpl implements A {
|
||||
int foo = 1;
|
||||
}
|
||||
|
||||
base class B implements BaseClass {
|
||||
int foo = 1;
|
||||
}
|
||||
|
||||
enum EnumInside implements ClassForEnum { x }
|
||||
|
||||
@@ -10,12 +10,8 @@
|
||||
import 'package:expect/expect.dart';
|
||||
import 'base_class_implement_lib.dart';
|
||||
|
||||
class AImpl implements A {
|
||||
@override
|
||||
int foo = 1;
|
||||
}
|
||||
|
||||
main() {
|
||||
Expect.equals(1, AImpl().foo);
|
||||
Expect.equals(1, B().foo);
|
||||
Expect.equals(0, EnumInside.x.index);
|
||||
}
|
||||
|
||||
+36
@@ -0,0 +1,36 @@
|
||||
// Copyright (c) 2023, 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 subtyping a base class where the subtype is not base, final or
|
||||
// sealed.
|
||||
|
||||
base class BaseClass {}
|
||||
base mixin BaseMixin {}
|
||||
|
||||
class Extends extends BaseClass {}
|
||||
// ^
|
||||
// [analyzer] unspecified
|
||||
// [cfe] unspecified
|
||||
|
||||
class Implements implements BaseClass {}
|
||||
// ^
|
||||
// [analyzer] unspecified
|
||||
// [cfe] unspecified
|
||||
|
||||
mixin MixinImplements implements BaseMixin {}
|
||||
// ^
|
||||
// [analyzer] unspecified
|
||||
// [cfe] unspecified
|
||||
|
||||
class With with BaseMixin {}
|
||||
// ^
|
||||
// [analyzer] unspecified
|
||||
// [cfe] unspecified
|
||||
|
||||
mixin On on BaseClass {}
|
||||
// ^
|
||||
// [analyzer] unspecified
|
||||
// [cfe] unspecified
|
||||
@@ -4,14 +4,16 @@
|
||||
|
||||
// SharedOptions=--enable-experiment=class-modifiers
|
||||
|
||||
// Other-library declarations used by base_class_mixin_on_test.dart.
|
||||
|
||||
base class BaseClass {}
|
||||
|
||||
abstract class A extends BaseClass {}
|
||||
abstract base class A extends BaseClass {}
|
||||
|
||||
class B extends BaseClass {}
|
||||
base class B extends BaseClass {}
|
||||
|
||||
base mixin BaseMixin {}
|
||||
|
||||
class C extends BaseClass with BaseMixin {}
|
||||
base class C extends BaseClass with BaseMixin {}
|
||||
|
||||
class D with BaseMixin {}
|
||||
base class D with BaseMixin {}
|
||||
|
||||
@@ -10,22 +10,22 @@
|
||||
import 'package:expect/expect.dart';
|
||||
import 'base_class_mixin_on_lib.dart';
|
||||
|
||||
mixin MA on BaseClass {}
|
||||
mixin MB on BaseClass {}
|
||||
base mixin MA on BaseClass {}
|
||||
base mixin MB on BaseClass {}
|
||||
|
||||
class ConcreteA extends A with MA, MB {
|
||||
base class ConcreteA extends A with MA, MB {
|
||||
int foo = 0;
|
||||
}
|
||||
|
||||
mixin MC on BaseClass, BaseMixin {}
|
||||
base mixin MC on BaseClass, BaseMixin {}
|
||||
|
||||
class ConcreteC extends C with MC {
|
||||
base class ConcreteC extends C with MC {
|
||||
int foo = 0;
|
||||
}
|
||||
|
||||
mixin MCSingular on BaseMixin {}
|
||||
base mixin MCSingular on BaseMixin {}
|
||||
|
||||
class ConcreteD extends D with MCSingular {
|
||||
base class ConcreteD extends D with MCSingular {
|
||||
int foo = 0;
|
||||
}
|
||||
|
||||
|
||||
@@ -4,11 +4,12 @@
|
||||
|
||||
// SharedOptions=--enable-experiment=class-modifiers
|
||||
|
||||
// Other declarations used by base_class_part_test.dart.
|
||||
|
||||
part of 'base_class_part_test.dart';
|
||||
|
||||
class A extends BaseClass {}
|
||||
base class A extends BaseClass {}
|
||||
|
||||
class B implements BaseClass {
|
||||
@override
|
||||
base class B implements BaseClass {
|
||||
int foo = 1;
|
||||
}
|
||||
|
||||
@@ -0,0 +1,74 @@
|
||||
// Copyright (c) 2023, 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,sealed-class
|
||||
|
||||
// Allow base mixins/classes to be subtyped by base, final, or sealed
|
||||
// classes/mixins and produce no error.
|
||||
|
||||
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 {
|
||||
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 {
|
||||
int foo = 0;
|
||||
}
|
||||
|
||||
base mixin MixinForEnum {}
|
||||
enum EnumWith with MixinForEnum { x }
|
||||
enum EnumImplements implements MixinForEnum { x }
|
||||
|
||||
main() {
|
||||
Expect.equals(0, BaseExtends().foo);
|
||||
Expect.equals(0, FinalExtends().foo);
|
||||
Expect.equals(0, SealedExtendsImpl().foo);
|
||||
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,22 +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.
|
||||
|
||||
// Make sure errors are emitted when trying to use base classes without
|
||||
// the `class-modifiers` experiment enabled.
|
||||
|
||||
base class BaseClass {}
|
||||
// ^
|
||||
// [analyzer] unspecified
|
||||
// [cfe] unspecified
|
||||
|
||||
mixin M {}
|
||||
base class BaseClassTypeAlias = Object with M;
|
||||
// ^
|
||||
// [analyzer] unspecified
|
||||
// [cfe] unspecified
|
||||
|
||||
base mixin BaseMixin {}
|
||||
// ^
|
||||
// [analyzer] unspecified
|
||||
// [cfe] unspecified
|
||||
@@ -9,37 +9,89 @@
|
||||
|
||||
abstract class BaseMembers {
|
||||
base int foo;
|
||||
// ^
|
||||
// [analyzer] unspecified
|
||||
// [cfe] unspecified
|
||||
//^^^^
|
||||
// [analyzer] COMPILE_TIME_ERROR.IMPLICIT_THIS_REFERENCE_IN_INITIALIZER
|
||||
// [analyzer] COMPILE_TIME_ERROR.NOT_A_TYPE
|
||||
// [cfe] 'base' isn't a type.
|
||||
// ^^^
|
||||
// [analyzer] SYNTACTIC_ERROR.EXPECTED_TOKEN
|
||||
// [cfe] Expected ';' after this.
|
||||
// ^^^
|
||||
// [analyzer] SYNTACTIC_ERROR.MISSING_CONST_FINAL_VAR_OR_TYPE
|
||||
// [cfe] Variables must be declared using the keywords 'const', 'final', 'var' or a type name.
|
||||
|
||||
int bar(base int x);
|
||||
// ^
|
||||
// [analyzer] unspecified
|
||||
// [cfe] unspecified
|
||||
//^^^
|
||||
// [analyzer] COMPILE_TIME_ERROR.NOT_A_TYPE
|
||||
// [cfe] 'int' isn't a type.
|
||||
// ^^^^
|
||||
// [analyzer] COMPILE_TIME_ERROR.NOT_A_TYPE
|
||||
// [cfe] 'base' isn't a type.
|
||||
// ^
|
||||
// [analyzer] SYNTACTIC_ERROR.EXPECTED_TOKEN
|
||||
// [cfe] Expected ')' before this.
|
||||
|
||||
base void bar2();
|
||||
// ^
|
||||
// [analyzer] unspecified
|
||||
// [cfe] unspecified
|
||||
//^^^^
|
||||
// [analyzer] SYNTACTIC_ERROR.EXPECTED_TOKEN
|
||||
// [analyzer] SYNTACTIC_ERROR.MISSING_CONST_FINAL_VAR_OR_TYPE
|
||||
// [cfe] Expected ';' after this.
|
||||
// [cfe] Variables must be declared using the keywords 'const', 'final', 'var' or a type name.
|
||||
}
|
||||
|
||||
base base class BaseDuplicateClass {}
|
||||
// ^
|
||||
// [analyzer] unspecified
|
||||
// [cfe] unspecified
|
||||
// [error column 1, length 4]
|
||||
// [analyzer] COMPILE_TIME_ERROR.NOT_A_TYPE
|
||||
// [cfe] 'base' isn't a type.
|
||||
// [cfe] Can't use 'base' because it is declared more than once.
|
||||
// ^^^^
|
||||
// [analyzer] SYNTACTIC_ERROR.EXPECTED_TOKEN
|
||||
// [cfe] Expected ';' after this.
|
||||
|
||||
base abstract class BaseAbstractClass {}
|
||||
// ^
|
||||
// [analyzer] unspecified
|
||||
// [cfe] unspecified
|
||||
// [error column 1, length 4]
|
||||
// [analyzer] COMPILE_TIME_ERROR.NOT_A_TYPE
|
||||
// [cfe] 'base' isn't a type.
|
||||
// [cfe] Can't use 'base' because it is declared more than once.
|
||||
// ^^^^^^^^
|
||||
// [analyzer] SYNTACTIC_ERROR.EXPECTED_TOKEN
|
||||
// [cfe] Expected ';' after this.
|
||||
|
||||
class BaseVariable {
|
||||
int foo() {
|
||||
base var x = 2;
|
||||
// ^
|
||||
// [analyzer] unspecified
|
||||
// [cfe] unspecified
|
||||
// ^^^^
|
||||
// [analyzer] SYNTACTIC_ERROR.EXPECTED_TOKEN
|
||||
// [cfe] Can't use 'base' because it is declared more than once.
|
||||
// [cfe] Expected ';' after this.
|
||||
return x;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
base extension StringExtension on String {}
|
||||
// [error column 1, length 4]
|
||||
// [analyzer] COMPILE_TIME_ERROR.NOT_A_TYPE
|
||||
// [analyzer] SYNTACTIC_ERROR.EXPECTED_TOKEN
|
||||
// [cfe] 'base' isn't a type.
|
||||
// [cfe] Expected ';' after this.
|
||||
// ^^^^^^^^^
|
||||
// [analyzer] SYNTACTIC_ERROR.MISSING_IDENTIFIER
|
||||
// [cfe] Expected an identifier, but got 'extension'.
|
||||
|
||||
base enum Enum { x }
|
||||
// [error column 1, length 4]
|
||||
// [analyzer] COMPILE_TIME_ERROR.DUPLICATE_DEFINITION
|
||||
// [analyzer] SYNTACTIC_ERROR.EXPECTED_TOKEN
|
||||
// [analyzer] SYNTACTIC_ERROR.MISSING_CONST_FINAL_VAR_OR_TYPE
|
||||
// [cfe] 'base' is already declared in this scope.
|
||||
// [cfe] Expected ';' after this.
|
||||
// [cfe] Variables must be declared using the keywords 'const', 'final', 'var' or a type name.
|
||||
|
||||
base typedef EnumTypedef = Enum;
|
||||
// [error column 1, length 4]
|
||||
// [analyzer] COMPILE_TIME_ERROR.DUPLICATE_DEFINITION
|
||||
// [analyzer] SYNTACTIC_ERROR.EXPECTED_TOKEN
|
||||
// [analyzer] SYNTACTIC_ERROR.MISSING_CONST_FINAL_VAR_OR_TYPE
|
||||
// [cfe] 'base' is already declared in this scope.
|
||||
// [cfe] Expected ';' after this.
|
||||
// [cfe] Variables must be declared using the keywords 'const', 'final', 'var' or a type name.
|
||||
|
||||
@@ -8,21 +8,19 @@
|
||||
|
||||
import 'base_class_typedef_lib.dart';
|
||||
|
||||
class BTypeDef implements BaseClassTypeDef {
|
||||
// ^^^^^^^^^^^^^^^^
|
||||
base class BTypeDef implements BaseClassTypeDef {
|
||||
// ^^^^^^^^^^^^^^^^
|
||||
// [analyzer] COMPILE_TIME_ERROR.INVALID_USE_OF_TYPE_OUTSIDE_LIBRARY
|
||||
// [cfe] The class 'BaseClass' can't be implemented outside of its library because it's a base class.
|
||||
@override
|
||||
int foo = 1;
|
||||
}
|
||||
|
||||
// Testing another layer of typedefs outside of the library.
|
||||
typedef BaseClassTypeDef2 = BaseClassTypeDef;
|
||||
|
||||
class BTypeDef2 implements BaseClassTypeDef2 {
|
||||
// ^^^^^^^^^^^^^^^^^
|
||||
base class BTypeDef2 implements BaseClassTypeDef2 {
|
||||
// ^^^^^^^^^^^^^^^^^
|
||||
// [analyzer] COMPILE_TIME_ERROR.INVALID_USE_OF_TYPE_OUTSIDE_LIBRARY
|
||||
// [cfe] The class 'BaseClass' can't be implemented outside of its library because it's a base class.
|
||||
@override
|
||||
int foo = 1;
|
||||
}
|
||||
|
||||
@@ -4,15 +4,17 @@
|
||||
|
||||
// SharedOptions=--enable-experiment=class-modifiers
|
||||
|
||||
// Other-library declarations used by
|
||||
// base_class_typedef_implement_error_test.dart.
|
||||
|
||||
base class BaseClass {
|
||||
int foo = 0;
|
||||
}
|
||||
|
||||
typedef BaseClassTypeDef = BaseClass;
|
||||
|
||||
class A extends BaseClassTypeDef {}
|
||||
base class A extends BaseClassTypeDef {}
|
||||
|
||||
class B implements BaseClassTypeDef {
|
||||
@override
|
||||
base class B implements BaseClassTypeDef {
|
||||
int foo = 1;
|
||||
}
|
||||
|
||||
@@ -4,14 +4,17 @@
|
||||
|
||||
// SharedOptions=--enable-experiment=class-modifiers
|
||||
|
||||
// Other-library declarations used by
|
||||
// base_class_typedef_outside_of_library_test.dart
|
||||
|
||||
import 'base_class_typedef_outside_of_library_lib2.dart';
|
||||
|
||||
base class BaseClass {
|
||||
int foo = 0;
|
||||
}
|
||||
|
||||
class A extends ATypeDef {}
|
||||
base class A extends ATypeDef {}
|
||||
|
||||
class B implements ATypeDef {
|
||||
base class B implements ATypeDef {
|
||||
int foo = 1;
|
||||
}
|
||||
|
||||
@@ -4,6 +4,9 @@
|
||||
|
||||
// SharedOptions=--enable-experiment=class-modifiers
|
||||
|
||||
// Other-library declarations used by
|
||||
// base_class_typedef_outside_of_library_test.dart
|
||||
|
||||
import "base_class_typedef_outside_of_library_lib.dart";
|
||||
|
||||
typedef ATypeDef = BaseClass;
|
||||
|
||||
@@ -12,8 +12,8 @@ import 'base_class_typedef_used_outside_lib.dart';
|
||||
|
||||
typedef ATypeDef = BaseClass;
|
||||
|
||||
class B implements ATypeDef {
|
||||
// ^^^^^^^^
|
||||
base class B implements ATypeDef {
|
||||
// ^^^^^^^^
|
||||
// [analyzer] COMPILE_TIME_ERROR.INVALID_USE_OF_TYPE_OUTSIDE_LIBRARY
|
||||
// [cfe] The class 'BaseClass' can't be implemented outside of its library because it's a base class.
|
||||
int foo = 1;
|
||||
|
||||
@@ -4,6 +4,9 @@
|
||||
|
||||
// SharedOptions=--enable-experiment=class-modifiers
|
||||
|
||||
// Other-library declarations used by
|
||||
// base_class_typedef_used_outside_error_test.dart.
|
||||
|
||||
base class BaseClass {
|
||||
int foo = 0;
|
||||
}
|
||||
|
||||
@@ -8,15 +8,19 @@
|
||||
|
||||
import 'base_mixin_implement_lib.dart';
|
||||
|
||||
abstract class AOutside implements BaseMixin {}
|
||||
// ^^^^^^^^^
|
||||
abstract base class AOutside implements BaseMixin {}
|
||||
// ^^^^^^^^^
|
||||
// [analyzer] COMPILE_TIME_ERROR.INVALID_USE_OF_TYPE_OUTSIDE_LIBRARY
|
||||
// [cfe] The mixin 'BaseMixin' can't be implemented outside of its library because it's a base mixin.
|
||||
|
||||
class BOutside implements BaseMixin {
|
||||
// ^^^^^^^^^
|
||||
base class BOutside implements BaseMixin {
|
||||
// ^^^^^^^^^
|
||||
// [analyzer] COMPILE_TIME_ERROR.INVALID_USE_OF_TYPE_OUTSIDE_LIBRARY
|
||||
// [cfe] The mixin 'BaseMixin' can't be implemented outside of its library because it's a base mixin.
|
||||
@override
|
||||
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 base mixin.
|
||||
|
||||
@@ -10,9 +10,10 @@ base mixin BaseMixin {
|
||||
int foo = 0;
|
||||
}
|
||||
|
||||
abstract class A implements BaseMixin {}
|
||||
base mixin MixinForEnum {}
|
||||
|
||||
class B implements BaseMixin {
|
||||
@override
|
||||
abstract base class A implements BaseMixin {}
|
||||
|
||||
base class B implements BaseMixin {
|
||||
int foo = 1;
|
||||
}
|
||||
|
||||
@@ -4,13 +4,16 @@
|
||||
|
||||
// SharedOptions=--enable-experiment=class-modifiers
|
||||
|
||||
// Library declarations used by
|
||||
// base_mixin_typedef_with_outside_test.dart and
|
||||
// base_mixin_typedef_with_test.dart.
|
||||
|
||||
base mixin BaseMixin {
|
||||
int foo = 0;
|
||||
}
|
||||
|
||||
typedef BaseMixinTypeDef = BaseMixin;
|
||||
|
||||
class A with BaseMixinTypeDef {
|
||||
@override
|
||||
base class A with BaseMixinTypeDef {
|
||||
int foo = 1;
|
||||
}
|
||||
|
||||
@@ -12,7 +12,7 @@ import 'base_mixin_typedef_with_lib.dart';
|
||||
|
||||
abstract base class AOutside with BaseMixinTypeDef {}
|
||||
|
||||
class AOutsideImpl extends AOutside {}
|
||||
base class AOutsideImpl extends AOutside {}
|
||||
|
||||
base class BOutside with BaseMixinTypeDef {}
|
||||
|
||||
|
||||
@@ -10,6 +10,10 @@ base mixin BaseMixin {
|
||||
int foo = 0;
|
||||
}
|
||||
|
||||
abstract class A with BaseMixin {}
|
||||
base mixin MixinForEnum {}
|
||||
|
||||
class B with BaseMixin {}
|
||||
abstract base class A with BaseMixin {}
|
||||
|
||||
base class B with BaseMixin {}
|
||||
|
||||
enum EnumInside with MixinForEnum { x }
|
||||
|
||||
@@ -4,8 +4,8 @@
|
||||
|
||||
// SharedOptions=--enable-experiment=class-modifiers
|
||||
|
||||
// Error when mixing in a base mixin where the class mixing it in is not base or
|
||||
// final.
|
||||
// Error when mixing in a base mixin where the class mixing it in is not base,
|
||||
// final, or sealed.
|
||||
|
||||
import 'base_mixin_with_lib.dart';
|
||||
|
||||
|
||||
@@ -11,11 +11,14 @@ import 'base_mixin_with_lib.dart';
|
||||
|
||||
abstract base class AOutside with BaseMixin {}
|
||||
|
||||
class AOutsideImpl extends AOutside {}
|
||||
base class AOutsideImpl extends AOutside {}
|
||||
|
||||
base class BOutside with BaseMixin {}
|
||||
|
||||
enum EnumOutside with MixinForEnum { x }
|
||||
|
||||
main() {
|
||||
Expect.equals(0, AOutsideImpl().foo);
|
||||
Expect.equals(0, BOutside().foo);
|
||||
Expect.equals(0, EnumOutside.x.index);
|
||||
}
|
||||
|
||||
@@ -9,9 +9,10 @@
|
||||
import 'package:expect/expect.dart';
|
||||
import 'base_mixin_with_lib.dart';
|
||||
|
||||
class AImpl extends A {}
|
||||
base class AImpl extends A {}
|
||||
|
||||
main() {
|
||||
Expect.equals(0, AImpl().foo);
|
||||
Expect.equals(0, B().foo);
|
||||
Expect.equals(0, EnumInside.x.index);
|
||||
}
|
||||
|
||||
@@ -13,11 +13,11 @@ abstract final class AlsoNotConstructable = Object with M;
|
||||
|
||||
main() {
|
||||
var error = NotConstructable();
|
||||
// ^
|
||||
// [analyzer] unspecified
|
||||
// [cfe] unspecified
|
||||
// ^^^^^^^^^^^^^^^^
|
||||
// [analyzer] COMPILE_TIME_ERROR.INSTANTIATE_ABSTRACT_CLASS
|
||||
// [cfe] The class 'NotConstructable' is abstract and can't be instantiated.
|
||||
var error2 = AlsoNotConstructable();
|
||||
// ^
|
||||
// [analyzer] unspecified
|
||||
// [cfe] unspecified
|
||||
// ^^^^^^^^^^^^^^^^^^^^
|
||||
// [analyzer] COMPILE_TIME_ERROR.INSTANTIATE_ABSTRACT_CLASS
|
||||
// [cfe] The class 'AlsoNotConstructable' is abstract and can't be instantiated.
|
||||
}
|
||||
|
||||
@@ -4,10 +4,13 @@
|
||||
|
||||
// SharedOptions=--enable-experiment=class-modifiers
|
||||
|
||||
// Library for having a `final` subtype on a `base` superclass outside its
|
||||
// library.
|
||||
|
||||
base class BaseClass {
|
||||
int foo = 0;
|
||||
}
|
||||
|
||||
base mixin BaseMixin {
|
||||
int foo = 0;
|
||||
int foo = 0;
|
||||
}
|
||||
|
||||
@@ -11,6 +11,8 @@ final class FinalClass {
|
||||
int foo = 0;
|
||||
}
|
||||
|
||||
abstract class A extends FinalClass {}
|
||||
abstract final class A extends FinalClass {}
|
||||
|
||||
class B extends FinalClass {}
|
||||
final class AImpl extends A {}
|
||||
|
||||
final class B extends FinalClass {}
|
||||
|
||||
@@ -8,13 +8,13 @@
|
||||
|
||||
import 'final_class_extend_lib.dart';
|
||||
|
||||
abstract class AOutside extends FinalClass {}
|
||||
// ^^^^^^^^^^
|
||||
abstract final class AOutside extends FinalClass {}
|
||||
// ^^^^^^^^^^
|
||||
// [analyzer] COMPILE_TIME_ERROR.INVALID_USE_OF_TYPE_OUTSIDE_LIBRARY
|
||||
// [cfe] The class 'FinalClass' can't be extended outside of its library because it's a final class.
|
||||
|
||||
class BOutside extends FinalClass {
|
||||
// ^^^^^^^^^^
|
||||
final class BOutside extends FinalClass {
|
||||
// ^^^^^^^^^^
|
||||
// [analyzer] COMPILE_TIME_ERROR.INVALID_USE_OF_TYPE_OUTSIDE_LIBRARY
|
||||
// [cfe] The class 'FinalClass' can't be extended outside of its library because it's a final class.
|
||||
}
|
||||
|
||||
@@ -10,8 +10,6 @@
|
||||
import 'package:expect/expect.dart';
|
||||
import 'final_class_extend_lib.dart';
|
||||
|
||||
class AImpl extends A {}
|
||||
|
||||
main() {
|
||||
Expect.equals(0, AImpl().foo);
|
||||
Expect.equals(0, B().foo);
|
||||
|
||||
@@ -13,7 +13,6 @@ final class FinalClass {
|
||||
}
|
||||
final class A extends FinalClass {}
|
||||
final class B implements FinalClass {
|
||||
@override
|
||||
int foo = 1;
|
||||
}
|
||||
|
||||
@@ -21,18 +20,17 @@ final mixin FinalMixin {
|
||||
int foo = 0;
|
||||
}
|
||||
final class C implements FinalMixin {
|
||||
@override
|
||||
int foo = 1;
|
||||
}
|
||||
final class AMixin with FinalMixin {}
|
||||
final class BMixin = Object with FinalMixin;
|
||||
|
||||
// Used for trivial runtime tests of the final subtypes.
|
||||
class AConcrete extends A {}
|
||||
class BConcrete extends B {}
|
||||
class CConcrete extends C {}
|
||||
class AMixinConcrete extends AMixin {}
|
||||
class BMixinConcrete extends BMixin {}
|
||||
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);
|
||||
|
||||
@@ -10,9 +10,16 @@ final class FinalClass {
|
||||
int foo = 0;
|
||||
}
|
||||
|
||||
abstract class A implements FinalClass {}
|
||||
final class ClassForEnum {}
|
||||
|
||||
class B implements FinalClass {
|
||||
@override
|
||||
abstract final class A implements FinalClass {}
|
||||
|
||||
final class AImpl implements A {
|
||||
int foo = 1;
|
||||
}
|
||||
|
||||
final class B implements FinalClass {
|
||||
int foo = 1;
|
||||
}
|
||||
|
||||
enum EnumInside implements ClassForEnum { x }
|
||||
|
||||
@@ -8,15 +8,19 @@
|
||||
|
||||
import 'final_class_implement_lib.dart';
|
||||
|
||||
abstract class AOutside implements FinalClass {}
|
||||
// ^^^^^^^^^^
|
||||
abstract final class AOutside implements FinalClass {}
|
||||
// ^^^^^^^^^^
|
||||
// [analyzer] COMPILE_TIME_ERROR.INVALID_USE_OF_TYPE_OUTSIDE_LIBRARY
|
||||
// [cfe] The class 'FinalClass' can't be implemented outside of its library because it's a final class.
|
||||
|
||||
class BOutside implements FinalClass {
|
||||
// ^^^^^^^^^^
|
||||
final class BOutside implements FinalClass {
|
||||
// ^^^^^^^^^^
|
||||
// [analyzer] COMPILE_TIME_ERROR.INVALID_USE_OF_TYPE_OUTSIDE_LIBRARY
|
||||
// [cfe] The class 'FinalClass' can't be implemented outside of its library because it's a final class.
|
||||
@override
|
||||
int foo = 1;
|
||||
}
|
||||
|
||||
enum EnumOutside implements ClassForEnum { x }
|
||||
// ^^^^^^^^^^^^
|
||||
// [analyzer] COMPILE_TIME_ERROR.INVALID_USE_OF_TYPE_OUTSIDE_LIBRARY
|
||||
// [cfe] The class 'ClassForEnum' can't be implemented outside of its library because it's a final class.
|
||||
|
||||
@@ -10,12 +10,8 @@
|
||||
import 'package:expect/expect.dart';
|
||||
import 'final_class_implement_lib.dart';
|
||||
|
||||
class AImpl implements A {
|
||||
@override
|
||||
int foo = 1;
|
||||
}
|
||||
|
||||
main() {
|
||||
Expect.equals(1, AImpl().foo);
|
||||
Expect.equals(1, B().foo);
|
||||
Expect.equals(0, EnumInside.x.index);
|
||||
}
|
||||
|
||||
+36
@@ -0,0 +1,36 @@
|
||||
// Copyright (c) 2023, 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 subtyping a final class where the subtype is not base, final or
|
||||
// sealed.
|
||||
|
||||
final class FinalClass {}
|
||||
final mixin FinalMixin {}
|
||||
|
||||
class Extends extends FinalClass {}
|
||||
// ^
|
||||
// [analyzer] unspecified
|
||||
// [cfe] unspecified
|
||||
|
||||
class Implements implements FinalClass {}
|
||||
// ^
|
||||
// [analyzer] unspecified
|
||||
// [cfe] unspecified
|
||||
|
||||
mixin MixinImplements implements FinalMixin {}
|
||||
// ^
|
||||
// [analyzer] unspecified
|
||||
// [cfe] unspecified
|
||||
|
||||
class With with FinalMixin {}
|
||||
// ^
|
||||
// [analyzer] unspecified
|
||||
// [cfe] unspecified
|
||||
|
||||
mixin On on FinalClass {}
|
||||
// ^
|
||||
// [analyzer] unspecified
|
||||
// [cfe] unspecified
|
||||
@@ -1,17 +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
|
||||
|
||||
final class FinalClass {}
|
||||
|
||||
abstract class A extends FinalClass {}
|
||||
|
||||
class B extends FinalClass {}
|
||||
|
||||
final mixin FinalMixin {}
|
||||
|
||||
class C extends FinalClass with FinalMixin {}
|
||||
|
||||
class D with FinalMixin {}
|
||||
@@ -4,28 +4,38 @@
|
||||
|
||||
// SharedOptions=--enable-experiment=class-modifiers
|
||||
|
||||
// Allow a final type to appear in the "on" clause of a mixin declaration in
|
||||
// another library.
|
||||
// Allow a final type to appear in the "on" clause of a mixin declaration.
|
||||
|
||||
import 'package:expect/expect.dart';
|
||||
import 'final_class_mixin_on_lib.dart';
|
||||
|
||||
mixin MA on FinalClass {}
|
||||
mixin MB on FinalClass {}
|
||||
final class FinalClass {}
|
||||
|
||||
class ConcreteA extends A with MA, MB {
|
||||
abstract final class A extends FinalClass {}
|
||||
|
||||
final class B extends FinalClass {}
|
||||
|
||||
final mixin FinalMixin {}
|
||||
|
||||
final class C extends FinalClass with FinalMixin {}
|
||||
|
||||
final class D with FinalMixin {}
|
||||
|
||||
final mixin MA on FinalClass {}
|
||||
final mixin MB on FinalClass {}
|
||||
|
||||
final class ConcreteA extends A with MA, MB {
|
||||
int foo = 0;
|
||||
}
|
||||
|
||||
mixin MC on FinalClass, FinalMixin {}
|
||||
final mixin MC on FinalClass, FinalMixin {}
|
||||
|
||||
class ConcreteC extends C with MC {
|
||||
final class ConcreteC extends C with MC {
|
||||
int foo = 0;
|
||||
}
|
||||
|
||||
mixin MCSingular on FinalMixin {}
|
||||
final mixin MCSingular on FinalMixin {}
|
||||
|
||||
class ConcreteD extends D with MCSingular {
|
||||
final class ConcreteD extends D with MCSingular {
|
||||
int foo = 0;
|
||||
}
|
||||
|
||||
|
||||
@@ -4,11 +4,12 @@
|
||||
|
||||
// SharedOptions=--enable-experiment=class-modifiers
|
||||
|
||||
// Library declarations used by final_class_part_test.dart.
|
||||
|
||||
part of 'final_class_part_test.dart';
|
||||
|
||||
class A extends FinalClass {}
|
||||
final class A extends FinalClass {}
|
||||
|
||||
class B implements FinalClass {
|
||||
@override
|
||||
final class B implements FinalClass {
|
||||
int foo = 1;
|
||||
}
|
||||
|
||||
+74
@@ -0,0 +1,74 @@
|
||||
// Copyright (c) 2023, 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,sealed-class
|
||||
|
||||
// Allow final mixins/classes to be subtyped by base, final, or sealed
|
||||
// classes/mixins and produce no error.
|
||||
|
||||
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 {
|
||||
int foo = 0;
|
||||
}
|
||||
|
||||
base mixin MixinForEnum {}
|
||||
enum EnumWith with MixinForEnum { x }
|
||||
enum EnumImplements implements MixinForEnum { x }
|
||||
|
||||
main() {
|
||||
Expect.equals(0, BaseExtends().foo);
|
||||
Expect.equals(0, FinalExtends().foo);
|
||||
Expect.equals(0, SealedExtendsImpl().foo);
|
||||
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);
|
||||
}
|
||||
@@ -4,15 +4,18 @@
|
||||
|
||||
// SharedOptions=--enable-experiment=class-modifiers
|
||||
|
||||
// Other-library declarations used by
|
||||
// final_class_typedef_subtype_error_test.dart and
|
||||
// final_class_typedef_test.dart.
|
||||
|
||||
final class FinalClass {
|
||||
int foo = 0;
|
||||
}
|
||||
|
||||
typedef FinalClassTypeDef = FinalClass;
|
||||
|
||||
class A extends FinalClassTypeDef {}
|
||||
final class A extends FinalClassTypeDef {}
|
||||
|
||||
class B implements FinalClassTypeDef {
|
||||
@override
|
||||
final class B implements FinalClassTypeDef {
|
||||
int foo = 1;
|
||||
}
|
||||
|
||||
+5
-2
@@ -4,14 +4,17 @@
|
||||
|
||||
// SharedOptions=--enable-experiment=class-modifiers
|
||||
|
||||
// Other-library declarations used by
|
||||
// final_class_typedef_outside_of_library_test.dart.
|
||||
|
||||
import 'final_class_typedef_outside_of_library_lib2.dart';
|
||||
|
||||
final class FinalClass {
|
||||
int foo = 0;
|
||||
}
|
||||
|
||||
class A extends ATypeDef {}
|
||||
final class A extends ATypeDef {}
|
||||
|
||||
class B implements ATypeDef {
|
||||
final class B implements ATypeDef {
|
||||
int foo = 1;
|
||||
}
|
||||
|
||||
@@ -4,6 +4,9 @@
|
||||
|
||||
// SharedOptions=--enable-experiment=class-modifiers
|
||||
|
||||
// Other-library declarations used by
|
||||
// final_class_typedef_outside_of_library_test.dart.
|
||||
|
||||
import 'final_class_typedef_outside_of_library_lib.dart';
|
||||
|
||||
typedef ATypeDef = FinalClass;
|
||||
|
||||
@@ -9,15 +9,14 @@
|
||||
|
||||
import 'final_class_typedef_lib.dart';
|
||||
|
||||
class ATypeDef extends FinalClassTypeDef {}
|
||||
// ^^^^^^^^^^^^^^^^^
|
||||
final class ATypeDef extends FinalClassTypeDef {}
|
||||
// ^^^^^^^^^^^^^^^^^
|
||||
// [analyzer] COMPILE_TIME_ERROR.INVALID_USE_OF_TYPE_OUTSIDE_LIBRARY
|
||||
// [cfe] The class 'FinalClass' can't be extended outside of its library because it's a final class.
|
||||
|
||||
class BTypeDef implements FinalClassTypeDef {
|
||||
// ^^^^^^^^^^^^^^^^^
|
||||
final class BTypeDef implements FinalClassTypeDef {
|
||||
// ^^^^^^^^^^^^^^^^^
|
||||
// [analyzer] COMPILE_TIME_ERROR.INVALID_USE_OF_TYPE_OUTSIDE_LIBRARY
|
||||
// [cfe] The class 'FinalClass' can't be implemented outside of its library because it's a final class.
|
||||
@override
|
||||
int foo = 1;
|
||||
}
|
||||
|
||||
+4
-4
@@ -12,13 +12,13 @@ import 'final_class_typedef_used_outside_lib.dart';
|
||||
|
||||
typedef ATypeDef = FinalClass;
|
||||
|
||||
class A extends ATypeDef {}
|
||||
// ^^^^^^^^
|
||||
final class A extends ATypeDef {}
|
||||
// ^^^^^^^^
|
||||
// [analyzer] COMPILE_TIME_ERROR.INVALID_USE_OF_TYPE_OUTSIDE_LIBRARY
|
||||
// [cfe] The class 'FinalClass' can't be extended outside of its library because it's a final class.
|
||||
|
||||
class B implements ATypeDef {
|
||||
// ^^^^^^^^
|
||||
final class B implements ATypeDef {
|
||||
// ^^^^^^^^
|
||||
// [analyzer] COMPILE_TIME_ERROR.INVALID_USE_OF_TYPE_OUTSIDE_LIBRARY
|
||||
// [cfe] The class 'FinalClass' can't be implemented outside of its library because it's a final class.
|
||||
int foo = 1;
|
||||
|
||||
@@ -4,6 +4,9 @@
|
||||
|
||||
// SharedOptions=--enable-experiment=class-modifiers
|
||||
|
||||
// Other-library declarations used by
|
||||
// final_class_typedef_used_outside_error_test.dart.
|
||||
|
||||
final class FinalClass {
|
||||
int foo = 0;
|
||||
}
|
||||
|
||||
@@ -10,9 +10,16 @@ final mixin FinalMixin {
|
||||
int foo = 0;
|
||||
}
|
||||
|
||||
abstract class A implements FinalMixin {}
|
||||
final mixin MixinForEnum {}
|
||||
|
||||
class B implements FinalMixin {
|
||||
@override
|
||||
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 }
|
||||
|
||||
@@ -8,15 +8,19 @@
|
||||
|
||||
import 'final_mixin_implement_lib.dart';
|
||||
|
||||
abstract class AOutside implements FinalMixin {}
|
||||
// ^^^^^^^^^^
|
||||
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.
|
||||
|
||||
class BOutside implements FinalMixin {
|
||||
// ^^^^^^^^^^
|
||||
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.
|
||||
@override
|
||||
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.
|
||||
|
||||
@@ -9,12 +9,8 @@
|
||||
import 'package:expect/expect.dart';
|
||||
import 'final_mixin_implement_lib.dart';
|
||||
|
||||
class AImpl implements A {
|
||||
@override
|
||||
int foo = 1;
|
||||
}
|
||||
|
||||
main() {
|
||||
Expect.equals(1, AImpl().foo);
|
||||
Expect.equals(1, B().foo);
|
||||
Expect.equals(0, EnumInside.x.index);
|
||||
}
|
||||
|
||||
@@ -4,13 +4,15 @@
|
||||
|
||||
// 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;
|
||||
|
||||
class A with FinalMixinTypeDef {
|
||||
@override
|
||||
final class A with FinalMixinTypeDef {
|
||||
int foo = 1;
|
||||
}
|
||||
|
||||
+4
-4
@@ -8,12 +8,12 @@
|
||||
|
||||
import 'final_mixin_typedef_with_lib.dart';
|
||||
|
||||
abstract class AOutside with FinalMixinTypeDef {}
|
||||
// ^^^^^^^^^^^^^^^^^
|
||||
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.
|
||||
|
||||
class BOutside with FinalMixinTypeDef {}
|
||||
// ^^^^^^^^^^^^^^^^^
|
||||
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.
|
||||
|
||||
@@ -10,6 +10,12 @@ final mixin FinalMixin {
|
||||
int foo = 0;
|
||||
}
|
||||
|
||||
abstract class A with FinalMixin {}
|
||||
final mixin MixinForEnum {}
|
||||
|
||||
class B with FinalMixin {}
|
||||
abstract final class A with FinalMixin {}
|
||||
|
||||
final class AImpl extends A {}
|
||||
|
||||
final class B with FinalMixin {}
|
||||
|
||||
enum EnumInside with MixinForEnum { x }
|
||||
|
||||
@@ -8,12 +8,17 @@
|
||||
|
||||
import 'final_mixin_with_lib.dart';
|
||||
|
||||
abstract class AOutside with FinalMixin {}
|
||||
// ^^^^^^^^^^
|
||||
abstract final class AOutside with FinalMixin {}
|
||||
// ^^^^^^^^^^
|
||||
// [analyzer] COMPILE_TIME_ERROR.INVALID_USE_OF_TYPE_OUTSIDE_LIBRARY
|
||||
// [cfe] unspecified
|
||||
// [cfe] The mixin 'FinalMixin' can't be mixed-in outside of its library because it's a final mixin.
|
||||
|
||||
class BOutside with FinalMixin {}
|
||||
// ^^^^^^^^^^
|
||||
final class BOutside with FinalMixin {}
|
||||
// ^^^^^^^^^^
|
||||
// [analyzer] COMPILE_TIME_ERROR.INVALID_USE_OF_TYPE_OUTSIDE_LIBRARY
|
||||
// [cfe] unspecified
|
||||
// [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.
|
||||
|
||||
@@ -9,9 +9,8 @@
|
||||
import 'package:expect/expect.dart';
|
||||
import 'final_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);
|
||||
}
|
||||
|
||||
+6
-6
@@ -13,11 +13,11 @@ abstract interface class AlsoNotConstructable = Object with M;
|
||||
|
||||
main() {
|
||||
var error = NotConstructable();
|
||||
// ^
|
||||
// [analyzer] unspecified
|
||||
// [cfe] unspecified
|
||||
// ^^^^^^^^^^^^^^^^
|
||||
// [analyzer] COMPILE_TIME_ERROR.INSTANTIATE_ABSTRACT_CLASS
|
||||
// [cfe] The class 'NotConstructable' is abstract and can't be instantiated.
|
||||
var error2 = AlsoNotConstructable();
|
||||
// ^
|
||||
// [analyzer] unspecified
|
||||
// [cfe] unspecified
|
||||
// ^^^^^^^^^^^^^^^^^^^^
|
||||
// [analyzer] COMPILE_TIME_ERROR.INSTANTIATE_ABSTRACT_CLASS
|
||||
// [cfe] The class 'AlsoNotConstructable' is abstract and can't be instantiated.
|
||||
}
|
||||
|
||||
@@ -11,9 +11,12 @@ interface class InterfaceClass {
|
||||
int foo = 0;
|
||||
}
|
||||
|
||||
interface class ClassForEnum {}
|
||||
|
||||
abstract class A implements InterfaceClass {}
|
||||
|
||||
class B implements InterfaceClass {
|
||||
@override
|
||||
int foo = 1;
|
||||
}
|
||||
|
||||
enum EnumInside implements ClassForEnum { x }
|
||||
|
||||
+3
-2
@@ -13,19 +13,20 @@ import 'interface_class_implement_lib.dart';
|
||||
abstract class AOutside implements InterfaceClass {}
|
||||
|
||||
class AOutsideImpl implements AOutside {
|
||||
@override
|
||||
int foo = 1;
|
||||
}
|
||||
|
||||
class DoesNotPreventExtension extends AOutsideImpl {}
|
||||
|
||||
class BOutside implements InterfaceClass {
|
||||
@override
|
||||
int foo = 1;
|
||||
}
|
||||
|
||||
enum EnumOutside implements ClassForEnum { x }
|
||||
|
||||
main() {
|
||||
Expect.equals(1, AOutsideImpl().foo);
|
||||
Expect.equals(1, DoesNotPreventExtension().foo);
|
||||
Expect.equals(1, BOutside().foo);
|
||||
Expect.equals(0, EnumOutside.x.index);
|
||||
}
|
||||
|
||||
@@ -11,11 +11,11 @@ import 'package:expect/expect.dart';
|
||||
import 'interface_class_implement_lib.dart';
|
||||
|
||||
class AImpl implements A {
|
||||
@override
|
||||
int foo = 1;
|
||||
}
|
||||
|
||||
main() {
|
||||
Expect.equals(1, AImpl().foo);
|
||||
Expect.equals(1, B().foo);
|
||||
Expect.equals(0, EnumInside.x.index);
|
||||
}
|
||||
|
||||
+1
-2
@@ -13,7 +13,6 @@ interface class InterfaceClass {
|
||||
}
|
||||
interface class A extends InterfaceClass {}
|
||||
interface class B implements InterfaceClass {
|
||||
@override
|
||||
int foo = 1;
|
||||
}
|
||||
|
||||
@@ -34,4 +33,4 @@ main() {
|
||||
Expect.equals(1, BConcrete().foo);
|
||||
Expect.equals(0, AMixinConcrete().foo);
|
||||
Expect.equals(0, BMixinConcrete().foo);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -4,6 +4,8 @@
|
||||
|
||||
// SharedOptions=--enable-experiment=class-modifiers
|
||||
|
||||
// Other-library declarations used by interface_class_mixin_on_test.dart.
|
||||
|
||||
interface class InterfaceClass {}
|
||||
|
||||
abstract class A extends InterfaceClass {}
|
||||
|
||||
@@ -4,11 +4,12 @@
|
||||
|
||||
// SharedOptions=--enable-experiment=class-modifiers
|
||||
|
||||
// Other-library declarations used by interface_class_part_test.dart.
|
||||
|
||||
part of 'interface_class_part_test.dart';
|
||||
|
||||
class A extends InterfaceClass {}
|
||||
|
||||
class B implements InterfaceClass {
|
||||
@override
|
||||
int foo = 1;
|
||||
}
|
||||
|
||||
-22
@@ -1,22 +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.
|
||||
|
||||
// Make sure errors are emitted when trying to use interface classes without
|
||||
// the `class-modifiers` experiment enabled.
|
||||
|
||||
interface class InterfaceClass {}
|
||||
// ^
|
||||
// [analyzer] unspecified
|
||||
// [cfe] unspecified
|
||||
|
||||
mixin M {}
|
||||
interface class InterfaceClassTypeAlias = Object with M;
|
||||
// ^
|
||||
// [analyzer] unspecified
|
||||
// [cfe] unspecified
|
||||
|
||||
interface mixin InterfaceMixin {}
|
||||
// ^
|
||||
// [analyzer] unspecified
|
||||
// [cfe] unspecified
|
||||
@@ -4,6 +4,9 @@
|
||||
|
||||
// SharedOptions=--enable-experiment=class-modifiers
|
||||
|
||||
// Other library declarations used by
|
||||
// interface_class_typedef_extend_error_test.dart.
|
||||
|
||||
interface class InterfaceClass {
|
||||
int foo = 0;
|
||||
}
|
||||
@@ -13,6 +16,5 @@ typedef InterfaceClassTypeDef = InterfaceClass;
|
||||
class A extends InterfaceClassTypeDef {}
|
||||
|
||||
class B implements InterfaceClassTypeDef {
|
||||
@override
|
||||
int foo = 1;
|
||||
}
|
||||
|
||||
+3
@@ -4,6 +4,9 @@
|
||||
|
||||
// SharedOptions=--enable-experiment=class-modifiers
|
||||
|
||||
// Other-library declarations used by
|
||||
// interface_class_typedef_outside_of_library_test.dart.
|
||||
|
||||
import 'interface_class_typedef_outside_of_library_lib2.dart';
|
||||
|
||||
interface class InterfaceClass {
|
||||
|
||||
+3
@@ -4,6 +4,9 @@
|
||||
|
||||
// SharedOptions=--enable-experiment=class-modifiers
|
||||
|
||||
// Other-library declarations used by
|
||||
// interface_class_typedef_outside_of_library_test.dart.
|
||||
|
||||
import "interface_class_typedef_outside_of_library_lib.dart";
|
||||
|
||||
typedef ATypeDef = InterfaceClass;
|
||||
|
||||
@@ -4,6 +4,9 @@
|
||||
|
||||
// SharedOptions=--enable-experiment=class-modifiers
|
||||
|
||||
// Other-library declarations used by
|
||||
// interface_class_typedef_used_outside_error_test.dart.
|
||||
|
||||
interface class InterfaceClass {
|
||||
int foo = 0;
|
||||
}
|
||||
|
||||
@@ -11,9 +11,10 @@ interface mixin InterfaceMixin {
|
||||
int foo = 0;
|
||||
}
|
||||
|
||||
interface mixin MixinForEnum {}
|
||||
|
||||
abstract class A implements InterfaceMixin {}
|
||||
|
||||
class B implements InterfaceMixin {
|
||||
@override
|
||||
int foo = 1;
|
||||
}
|
||||
|
||||
+3
-2
@@ -13,16 +13,17 @@ import 'interface_mixin_implement_lib.dart';
|
||||
abstract class AOutside implements InterfaceMixin {}
|
||||
|
||||
class AOutsideImpl implements AOutside {
|
||||
@override
|
||||
int foo = 1;
|
||||
}
|
||||
|
||||
class BOutside implements InterfaceMixin {
|
||||
@override
|
||||
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);
|
||||
}
|
||||
|
||||
@@ -4,6 +4,10 @@
|
||||
|
||||
// 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;
|
||||
}
|
||||
@@ -11,6 +15,5 @@ interface mixin InterfaceMixin {
|
||||
typedef InterfaceMixinTypeDef = InterfaceMixin;
|
||||
|
||||
class A with InterfaceMixinTypeDef {
|
||||
@override
|
||||
int foo = 1;
|
||||
}
|
||||
|
||||
@@ -10,6 +10,10 @@ interface mixin InterfaceMixin {
|
||||
int foo = 0;
|
||||
}
|
||||
|
||||
interface mixin MixinForEnum {}
|
||||
|
||||
abstract class A with InterfaceMixin {}
|
||||
|
||||
class B with InterfaceMixin {}
|
||||
|
||||
enum EnumInside implements MixinForEnum { x }
|
||||
|
||||
@@ -17,3 +17,8 @@ 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.
|
||||
|
||||
@@ -14,4 +14,5 @@ class AImpl extends A {}
|
||||
main() {
|
||||
Expect.equals(0, AImpl().foo);
|
||||
Expect.equals(0, B().foo);
|
||||
Expect.equals(0, EnumInside.x.index);
|
||||
}
|
||||
|
||||
@@ -0,0 +1,25 @@
|
||||
// Copyright (c) 2023, 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
|
||||
// @dart = 2.19
|
||||
|
||||
// Make sure errors are emitted when trying to use base classes without
|
||||
// the `class-modifiers` experiment enabled.
|
||||
|
||||
base class BaseClass {}
|
||||
// [error column 1, length 4]
|
||||
// [analyzer] SYNTACTIC_ERROR.EXPERIMENT_NOT_ENABLED
|
||||
// [cfe] The 'class-modifiers' language feature is disabled for this library.
|
||||
|
||||
mixin M {}
|
||||
base class BaseClassTypeAlias = Object with M;
|
||||
// [error column 1, length 4]
|
||||
// [analyzer] SYNTACTIC_ERROR.EXPERIMENT_NOT_ENABLED
|
||||
// [cfe] The 'class-modifiers' language feature is disabled for this library.
|
||||
|
||||
base mixin BaseMixin {}
|
||||
// [error column 1, length 4]
|
||||
// [analyzer] SYNTACTIC_ERROR.EXPERIMENT_NOT_ENABLED
|
||||
// [cfe] The 'class-modifiers' language feature is disabled for this library.
|
||||
+7
-4
@@ -1,22 +1,25 @@
|
||||
// Copyright (c) 2022, the Dart project authors. Please see the AUTHORS file
|
||||
// Copyright (c) 2023, 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
|
||||
// @dart = 2.19
|
||||
|
||||
// Make sure errors are emitted when trying to use final classes without
|
||||
// the `class-modifiers` experiment enabled.
|
||||
|
||||
final class FinalClass {}
|
||||
// [error column 1, length 5]
|
||||
// [analyzer] SYNTACTIC_ERROR.EXPERIMENT_NOT_ENABLED
|
||||
// [cfe] This requires the experimental 'class-modifiers' language feature to be enabled.
|
||||
// [cfe] The 'class-modifiers' language feature is disabled for this library.
|
||||
|
||||
mixin M {}
|
||||
final class FinalClassTypeAlias = Object with M;
|
||||
// [error column 1, length 5]
|
||||
// [analyzer] SYNTACTIC_ERROR.EXPERIMENT_NOT_ENABLED
|
||||
// [cfe] This requires the experimental 'class-modifiers' language feature to be 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] This requires the experimental 'class-modifiers' language feature to be enabled.
|
||||
// [cfe] The 'class-modifiers' language feature is disabled for this library.
|
||||
@@ -0,0 +1,25 @@
|
||||
// Copyright (c) 2023, 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
|
||||
// @dart = 2.19
|
||||
|
||||
// Make sure errors are emitted when trying to use interface classes without
|
||||
// the `class-modifiers` experiment enabled.
|
||||
|
||||
interface class InterfaceClass {}
|
||||
// [error column 1, length 9]
|
||||
// [analyzer] SYNTACTIC_ERROR.EXPERIMENT_NOT_ENABLED
|
||||
// [cfe] The 'class-modifiers' language feature is disabled for this library.
|
||||
|
||||
mixin M {}
|
||||
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.
|
||||
+6
-3
@@ -2,21 +2,24 @@
|
||||
// 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
|
||||
// @dart = 2.19
|
||||
|
||||
// Make sure errors are emitted when trying to use mixin classes without
|
||||
// the `class-modifiers` experiment enabled.
|
||||
|
||||
mixin class MixinClass {}
|
||||
// [error column 1, length 5]
|
||||
// [analyzer] SYNTACTIC_ERROR.EXPERIMENT_NOT_ENABLED
|
||||
// [cfe] This requires the experimental 'class-modifiers' language feature to be enabled.
|
||||
// [cfe] The 'class-modifiers' language feature is disabled for this library.
|
||||
|
||||
abstract mixin class AbstractMixinClass {}
|
||||
// ^^^^^
|
||||
// [analyzer] SYNTACTIC_ERROR.EXPERIMENT_NOT_ENABLED
|
||||
// [cfe] This requires the experimental 'class-modifiers' language feature to be enabled.
|
||||
// [cfe] The 'class-modifiers' language feature is disabled for this library.
|
||||
|
||||
mixin M {}
|
||||
mixin class NamedMixinClassApplication = Object with M;
|
||||
// [error column 1, length 5]
|
||||
// [analyzer] SYNTACTIC_ERROR.EXPERIMENT_NOT_ENABLED
|
||||
// [cfe] This requires the experimental 'class-modifiers' language feature to be enabled.
|
||||
// [cfe] The 'class-modifiers' language feature is disabled for this library.
|
||||
@@ -4,6 +4,9 @@
|
||||
|
||||
// SharedOptions=--enable-experiment=class-modifiers
|
||||
|
||||
// Other-library declarations used by
|
||||
// mixin_class_no_modifier_outside_library_error_test.dart.
|
||||
|
||||
class Class {
|
||||
int foo = 0;
|
||||
}
|
||||
|
||||
@@ -4,6 +4,9 @@
|
||||
|
||||
// @dart = 2.19
|
||||
|
||||
// Testing usage of classes as mixins with no 'mixin' modifier in an older
|
||||
// version.
|
||||
|
||||
class Class {
|
||||
int foo = 0;
|
||||
}
|
||||
|
||||
-1
@@ -13,7 +13,6 @@ class SubclassNotObject with NonObjectSuperclassClass {
|
||||
// ^^^^^^^^^^^^^^^^^^^^^^^^
|
||||
// [analyzer] COMPILE_TIME_ERROR.MIXIN_INHERITS_FROM_NOT_OBJECT
|
||||
// [cfe] The class 'NonObjectSuperclassClass' can't be used as a mixin because it extends a class other than 'Object'.
|
||||
@override
|
||||
int foo = 1;
|
||||
}
|
||||
|
||||
|
||||
@@ -4,6 +4,8 @@
|
||||
|
||||
// SharedOptions=--enable-experiment=class-modifiers
|
||||
|
||||
// Other-library declarations used by mixin_class_part_test.dart.
|
||||
|
||||
part of 'mixin_class_part_test.dart';
|
||||
|
||||
class A with MixinClass {}
|
||||
|
||||
@@ -79,3 +79,10 @@ mixin typedef T = String;
|
||||
// [analyzer] SYNTACTIC_ERROR.MISSING_IDENTIFIER
|
||||
// [cfe] A mixin declaration must have a body, even if it is empty.
|
||||
// [cfe] Expected an identifier, but got 'typedef'.
|
||||
|
||||
mixin extension StringExtension on String {}
|
||||
// ^^^^^^^^^
|
||||
// [analyzer] SYNTACTIC_ERROR.EXPECTED_BODY
|
||||
// [analyzer] SYNTACTIC_ERROR.MISSING_IDENTIFIER
|
||||
// [cfe] A mixin declaration must have a body, even if it is empty.
|
||||
// [cfe] Expected an identifier, but got 'extension'.
|
||||
|
||||
@@ -4,6 +4,8 @@
|
||||
|
||||
// SharedOptions=--enable-experiment=class-modifiers
|
||||
|
||||
// Other-library declarations used by mixin_class_typedef_test.dart.
|
||||
|
||||
mixin class MixinClass {
|
||||
int foo = 0;
|
||||
}
|
||||
|
||||
@@ -4,6 +4,9 @@
|
||||
|
||||
// SharedOptions=--enable-experiment=class-modifiers
|
||||
|
||||
// Other-library declarations used by
|
||||
// mixin_class_typedef_outside_of_library_test.dart.
|
||||
|
||||
import 'mixin_class_typedef_outside_of_library_lib2.dart';
|
||||
|
||||
mixin class MixinClass {
|
||||
|
||||
@@ -4,6 +4,9 @@
|
||||
|
||||
// SharedOptions=--enable-experiment=class-modifiers
|
||||
|
||||
// Other-library declarations used by
|
||||
// mixin_class_typedef_outside_of_library_test.dart.
|
||||
|
||||
import 'mixin_class_typedef_outside_of_library_lib.dart';
|
||||
|
||||
typedef ATypeDef = MixinClass;
|
||||
|
||||
@@ -4,6 +4,9 @@
|
||||
|
||||
// SharedOptions=--enable-experiment=class-modifiers
|
||||
|
||||
// Other-library declarations used by
|
||||
// mixin_class_typedef_used_outside_test.dart.
|
||||
|
||||
mixin class MixinClass {
|
||||
int foo = 0;
|
||||
}
|
||||
|
||||
@@ -21,10 +21,7 @@ class OutsideB with SealedClass {
|
||||
// [analyzer] COMPILE_TIME_ERROR.INVALID_USE_OF_TYPE_OUTSIDE_LIBRARY
|
||||
// [cfe] The class 'SealedClass' can't be used as a mixin because it isn't a mixin class nor a mixin.
|
||||
// [cfe] The mixin 'SealedClass' can't be mixed in outside of its library because it's a sealed mixin.
|
||||
@override
|
||||
int foo = 2;
|
||||
|
||||
@override
|
||||
int bar(int value) => value;
|
||||
}
|
||||
|
||||
|
||||
@@ -4,6 +4,8 @@
|
||||
|
||||
// SharedOptions=--enable-experiment=sealed-class,class-modifiers
|
||||
|
||||
// Other-library declarations used by sealed_class_as_mixin_error_test.dart.
|
||||
|
||||
sealed class SealedClass {
|
||||
int nonAbstractFoo = 0;
|
||||
abstract int foo;
|
||||
|
||||
@@ -17,9 +17,6 @@ class OutsideB extends SealedClass {
|
||||
// ^^^^^^^^^^^
|
||||
// [analyzer] COMPILE_TIME_ERROR.INVALID_USE_OF_TYPE_OUTSIDE_LIBRARY
|
||||
// [cfe] The class 'SealedClass' can't be extended, implemented, or mixed in outside of its library because it's a sealed class.
|
||||
@override
|
||||
int foo = 2;
|
||||
|
||||
@override
|
||||
int bar(int value) => value;
|
||||
}
|
||||
|
||||
@@ -4,6 +4,9 @@
|
||||
|
||||
// SharedOptions=--enable-experiment=sealed-class
|
||||
|
||||
// Other-library declarations used by sealed_class_extend_test.dart and
|
||||
// sealed_class_extend_error_test.dart.
|
||||
|
||||
sealed class SealedClass {
|
||||
int nonAbstractFoo = 0;
|
||||
abstract int foo;
|
||||
@@ -14,20 +17,12 @@ sealed class SealedClass {
|
||||
abstract class A extends SealedClass {}
|
||||
|
||||
class AImpl extends A {
|
||||
@override
|
||||
int foo = 1;
|
||||
|
||||
@override
|
||||
int bar(int value) => value + 1;
|
||||
}
|
||||
|
||||
class B extends SealedClass {
|
||||
@override
|
||||
int nonAbstractFoo = 100;
|
||||
|
||||
@override
|
||||
int foo = 2;
|
||||
|
||||
@override
|
||||
int bar(int value) => value;
|
||||
}
|
||||
|
||||
@@ -11,24 +11,14 @@ import "package:expect/expect.dart";
|
||||
import 'sealed_class_extend_lib.dart';
|
||||
|
||||
class AExtends extends A {
|
||||
@override
|
||||
int foo = 0;
|
||||
|
||||
@override
|
||||
int bar(int value) => value;
|
||||
}
|
||||
|
||||
class AImplements implements A {
|
||||
@override
|
||||
int nonAbstractFoo = 0;
|
||||
|
||||
@override
|
||||
int foo = 0;
|
||||
|
||||
@override
|
||||
int bar(int value) => value;
|
||||
|
||||
@override
|
||||
int nonAbstractBar(int value) => value;
|
||||
}
|
||||
|
||||
|
||||
@@ -17,16 +17,9 @@ class OutsideB implements SealedClass {
|
||||
// ^^^^^^^^^^^
|
||||
// [analyzer] COMPILE_TIME_ERROR.INVALID_USE_OF_TYPE_OUTSIDE_LIBRARY
|
||||
// [cfe] The class 'SealedClass' can't be extended, implemented, or mixed in outside of its library because it's a sealed class.
|
||||
@override
|
||||
int nonAbstractFoo = 2;
|
||||
|
||||
@override
|
||||
int foo = 2;
|
||||
|
||||
@override
|
||||
int nonAbstractBar(int value) => value;
|
||||
|
||||
@override
|
||||
int bar(int value) => value;
|
||||
}
|
||||
|
||||
@@ -34,3 +27,8 @@ mixin OutsideMixin implements SealedClass {}
|
||||
// ^^^^^^^^^^^
|
||||
// [analyzer] COMPILE_TIME_ERROR.INVALID_USE_OF_TYPE_OUTSIDE_LIBRARY
|
||||
// [cfe] The class 'SealedClass' can't be extended, implemented, or mixed in outside of its library because it's a sealed class.
|
||||
|
||||
enum EnumOutside implements ClassForEnum { x }
|
||||
// ^^^^^^^^^^^^
|
||||
// [analyzer] COMPILE_TIME_ERROR.INVALID_USE_OF_TYPE_OUTSIDE_LIBRARY
|
||||
// [cfe] The class 'ClassForEnum' can't be extended, implemented, or mixed in outside of its library because it's a sealed class.
|
||||
|
||||
@@ -4,6 +4,9 @@
|
||||
|
||||
// SharedOptions=--enable-experiment=sealed-class
|
||||
|
||||
// Other-library declarations used by sealed_class_implement_test.dart and
|
||||
// sealed_class_implement_error_test.dart.
|
||||
|
||||
sealed class SealedClass {
|
||||
int nonAbstractFoo = 0;
|
||||
abstract int foo;
|
||||
@@ -11,32 +14,22 @@ sealed class SealedClass {
|
||||
int bar(int value);
|
||||
}
|
||||
|
||||
sealed class ClassForEnum {}
|
||||
|
||||
abstract class A implements SealedClass {}
|
||||
|
||||
class AImpl implements A {
|
||||
@override
|
||||
int nonAbstractFoo = 0;
|
||||
|
||||
@override
|
||||
int foo = 1;
|
||||
|
||||
@override
|
||||
int nonAbstractBar(int value) => value + 100;
|
||||
|
||||
@override
|
||||
int bar(int value) => value + 1;
|
||||
}
|
||||
|
||||
class B implements SealedClass {
|
||||
@override
|
||||
int nonAbstractFoo = 100;
|
||||
|
||||
@override
|
||||
int foo = 2;
|
||||
|
||||
@override
|
||||
int nonAbstractBar(int value) => value + 100;
|
||||
|
||||
@override
|
||||
int bar(int value) => value;
|
||||
}
|
||||
|
||||
enum EnumInside implements ClassForEnum { x }
|
||||
|
||||
@@ -12,30 +12,16 @@ import "package:expect/expect.dart";
|
||||
import 'sealed_class_implement_lib.dart';
|
||||
|
||||
class AExtends extends A {
|
||||
@override
|
||||
int nonAbstractFoo = 0;
|
||||
|
||||
@override
|
||||
int foo = 0;
|
||||
|
||||
@override
|
||||
int bar(int value) => value;
|
||||
|
||||
@override
|
||||
int nonAbstractBar(int value) => value;
|
||||
}
|
||||
|
||||
class AImplements implements A {
|
||||
@override
|
||||
int nonAbstractFoo = 0;
|
||||
|
||||
@override
|
||||
int foo = 0;
|
||||
|
||||
@override
|
||||
int bar(int value) => value;
|
||||
|
||||
@override
|
||||
int nonAbstractBar(int value) => value;
|
||||
}
|
||||
|
||||
@@ -63,4 +49,6 @@ main() {
|
||||
Expect.equals(0, aImplements.foo);
|
||||
Expect.equals(0, aImplements.bar(0));
|
||||
Expect.equals(0, aImplements.nonAbstractBar(0));
|
||||
|
||||
Expect.equals(0, EnumInside.x.index);
|
||||
}
|
||||
|
||||
@@ -4,6 +4,8 @@
|
||||
|
||||
// SharedOptions=--enable-experiment=sealed-class
|
||||
|
||||
// Other-library declarations used by sealed_class_mixin_on_test.dart.
|
||||
|
||||
sealed class SealedClass {}
|
||||
|
||||
abstract class A extends SealedClass {}
|
||||
|
||||
@@ -4,11 +4,12 @@
|
||||
|
||||
// SharedOptions=--enable-experiment=sealed-class
|
||||
|
||||
// Other-library declarations used by sealed_class_part_test.dart.
|
||||
|
||||
part of 'sealed_class_part_test.dart';
|
||||
|
||||
class A extends SealedClass {}
|
||||
|
||||
class B implements SealedClass {
|
||||
@override
|
||||
int foo = 1;
|
||||
}
|
||||
|
||||
@@ -2,13 +2,16 @@
|
||||
// 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
|
||||
// @dart = 2.19
|
||||
|
||||
// Make sure errors are emitted when trying to use sealed classes without
|
||||
// the `sealed` experiment enabled.
|
||||
|
||||
sealed class SealedClass {
|
||||
// [error column 1, length 6]
|
||||
// [analyzer] SYNTACTIC_ERROR.EXPERIMENT_NOT_ENABLED
|
||||
// [cfe] This requires the experimental 'sealed-class' language feature to be enabled.
|
||||
// [cfe] The 'sealed-class' language feature is disabled for this library.
|
||||
// ^
|
||||
// [cfe] The non-abstract class 'SealedClass' is missing implementations for these members:
|
||||
int nonAbstractFoo = 0;
|
||||
@@ -21,34 +24,13 @@ sealed class SealedClass {
|
||||
// [analyzer] COMPILE_TIME_ERROR.CONCRETE_CLASS_WITH_ABSTRACT_MEMBER
|
||||
}
|
||||
|
||||
abstract class A extends SealedClass {}
|
||||
|
||||
class AImpl extends A {
|
||||
@override
|
||||
int foo = 1;
|
||||
|
||||
@override
|
||||
int bar(int value) => value + 1;
|
||||
}
|
||||
|
||||
class B extends SealedClass {
|
||||
@override
|
||||
int nonAbstractFoo = 100;
|
||||
|
||||
@override
|
||||
int foo = 2;
|
||||
|
||||
@override
|
||||
int bar(int value) => value;
|
||||
}
|
||||
|
||||
mixin M {}
|
||||
sealed class SealedClassTypeAlias = Object with M;
|
||||
// [error column 1, length 6]
|
||||
// [analyzer] SYNTACTIC_ERROR.EXPERIMENT_NOT_ENABLED
|
||||
// [cfe] This requires the experimental 'sealed-class' language feature to be 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] This requires the experimental 'sealed-class' language feature to be enabled.
|
||||
// [cfe] The 'sealed-class' language feature is disabled for this library.
|
||||
|
||||
@@ -54,6 +54,7 @@ sealed sealed class SealedDuplicateClass {}
|
||||
// [error column 1, length 6]
|
||||
// [analyzer] COMPILE_TIME_ERROR.NOT_A_TYPE
|
||||
// [cfe] 'sealed' isn't a type.
|
||||
// [cfe] Can't use 'sealed' because it is declared more than once.
|
||||
// ^^^^^^
|
||||
// [analyzer] SYNTACTIC_ERROR.EXPECTED_TOKEN
|
||||
// [cfe] Expected ';' after this.
|
||||
@@ -63,7 +64,36 @@ class SealedVariable {
|
||||
sealed var x = 2;
|
||||
// ^^^^^^
|
||||
// [analyzer] SYNTACTIC_ERROR.EXPECTED_TOKEN
|
||||
// [cfe] Can't use 'sealed' because it is declared more than once.
|
||||
// [cfe] Expected ';' after this.
|
||||
return x;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
sealed extension StringExtension on String {}
|
||||
// [error column 1, length 6]
|
||||
// [analyzer] COMPILE_TIME_ERROR.NOT_A_TYPE
|
||||
// [analyzer] SYNTACTIC_ERROR.EXPECTED_TOKEN
|
||||
// [cfe] 'sealed' isn't a type.
|
||||
// [cfe] Expected ';' after this.
|
||||
// ^^^^^^^^^
|
||||
// [analyzer] SYNTACTIC_ERROR.MISSING_IDENTIFIER
|
||||
// [cfe] Expected an identifier, but got 'extension'.
|
||||
|
||||
sealed enum Enum { x }
|
||||
// [error column 1, length 6]
|
||||
// [analyzer] COMPILE_TIME_ERROR.DUPLICATE_DEFINITION
|
||||
// [analyzer] SYNTACTIC_ERROR.EXPECTED_TOKEN
|
||||
// [analyzer] SYNTACTIC_ERROR.MISSING_CONST_FINAL_VAR_OR_TYPE
|
||||
// [cfe] 'sealed' is already declared in this scope.
|
||||
// [cfe] Expected ';' after this.
|
||||
// [cfe] Variables must be declared using the keywords 'const', 'final', 'var' or a type name.
|
||||
|
||||
sealed typedef EnumTypedef = Enum;
|
||||
// [error column 1, length 6]
|
||||
// [analyzer] COMPILE_TIME_ERROR.DUPLICATE_DEFINITION
|
||||
// [analyzer] SYNTACTIC_ERROR.EXPECTED_TOKEN
|
||||
// [analyzer] SYNTACTIC_ERROR.MISSING_CONST_FINAL_VAR_OR_TYPE
|
||||
// [cfe] 'sealed' is already declared in this scope.
|
||||
// [cfe] Expected ';' after this.
|
||||
// [cfe] Variables must be declared using the keywords 'const', 'final', 'var' or a type name.
|
||||
|
||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user