forked from dart-lang/co19
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
dart-lang#1959. Tests for class modifiers restrictions and type aliases
- Loading branch information
Showing
18 changed files
with
1,717 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
80 changes: 80 additions & 0 deletions
80
LanguageFeatures/Class-modifiers/basic_restrictions_A01_t09.dart
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,80 @@ | ||
// 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. | ||
|
||
/// @assertion It is a compile-time error if: | ||
/// - A declaration depends directly on a sealed declaration from another | ||
/// library. | ||
/// | ||
/// @description Check that it is a compile-time error if class marked `sealed` | ||
/// is extended outside of the library where it is declared. Test type aliases | ||
/// @author [email protected] | ||
// SharedOptions=--enable-experiment=class-modifiers | ||
|
||
import "class_modifiers_lib.dart"; | ||
|
||
class ExtendsSealed extends TypedefSealedClass {} | ||
// ^^^^^^^^^^^^^^^^^^ | ||
// [analyzer] unspecified | ||
// [cfe] unspecified | ||
|
||
base class BaseExtendsSealed extends TypedefSealedClass {} | ||
// ^^^^^^^^^^^^^^^^^^ | ||
// [analyzer] unspecified | ||
// [cfe] unspecified | ||
|
||
interface class InterfaceExtendsSealed extends TypedefSealedClass {} | ||
// ^^^^^^^^^^^^^^^^^^ | ||
// [analyzer] unspecified | ||
// [cfe] unspecified | ||
|
||
final class FinalExtendsSealed extends TypedefSealedClass {} | ||
// ^^^^^^^^^^^^^^^^^^ | ||
// [analyzer] unspecified | ||
// [cfe] unspecified | ||
|
||
sealed class SealedExtendsSealed extends TypedefSealedClass {} | ||
// ^^^^^^^^^^^^^^^^^^ | ||
// [analyzer] unspecified | ||
// [cfe] unspecified | ||
|
||
abstract class AbstractExtendsSealed extends TypedefSealedClass {} | ||
// ^^^^^^^^^^^^^^^^^^ | ||
// [analyzer] unspecified | ||
// [cfe] unspecified | ||
|
||
abstract base class AbstractBaseExtendsSealed extends TypedefSealedClass {} | ||
// ^^^^^^^^^^^^^^^^^^ | ||
// [analyzer] unspecified | ||
// [cfe] unspecified | ||
|
||
abstract interface class AbstractInterfaceExtendsSealed extends TypedefSealedClass {} | ||
// ^^^^^^^^^^^^^^^^^^ | ||
// [analyzer] unspecified | ||
// [cfe] unspecified | ||
|
||
abstract final class AbstractFinalExtendsSealed extends TypedefSealedClass {} | ||
// ^^^^^^^^^^^^^^^^^^ | ||
// [analyzer] unspecified | ||
// [cfe] unspecified | ||
|
||
typedef LocalTypedefSealedClass = SealedClass; | ||
|
||
class ExtendsLocalTypedefSealedClass extends LocalTypedefSealedClass {} | ||
// ^^^^^^^^^^^^^^^^^^^^^^^ | ||
// [analyzer] unspecified | ||
// [cfe] unspecified | ||
|
||
main() { | ||
print(ExtendsSealed); | ||
print(AbstractExtendsSealed); | ||
print(AbstractBaseExtendsSealed); | ||
print(AbstractInterfaceExtendsSealed); | ||
print(AbstractFinalExtendsSealed); | ||
print(FinalExtendsSealed); | ||
print(BaseExtendsSealed); | ||
print(SealedExtendsSealed); | ||
print(InterfaceExtendsSealed); | ||
print(ExtendsLocalTypedefSealedClass); | ||
} |
123 changes: 123 additions & 0 deletions
123
LanguageFeatures/Class-modifiers/basic_restrictions_A01_t10.dart
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,123 @@ | ||
// 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. | ||
|
||
/// @assertion It is a compile-time error if: | ||
/// - A declaration depends directly on a sealed declaration from another | ||
/// library. | ||
/// | ||
/// @description Check that it is a compile-time error to implement the | ||
/// interface of a class marked `sealed` outside of the library where it is | ||
/// declared. Test type aliases | ||
/// @author [email protected] | ||
// SharedOptions=--enable-experiment=class-modifiers | ||
|
||
import "class_modifiers_lib.dart"; | ||
|
||
class ImplementsSealed implements TypedefSealedClass {} | ||
// ^^^^^^^^^^^^^^^^^^ | ||
// [analyzer] unspecified | ||
// [cfe] unspecified | ||
|
||
base class BaseImplementsSealed implements TypedefSealedClass {} | ||
// ^^^^^^^^^^^^^^^^^^ | ||
// [analyzer] unspecified | ||
// [cfe] unspecified | ||
|
||
interface class InterfaceImplementsSealed implements TypedefSealedClass {} | ||
// ^^^^^^^^^^^^^^^^^^ | ||
// [analyzer] unspecified | ||
// [cfe] unspecified | ||
|
||
final class FinalImplementsSealed implements TypedefSealedClass {} | ||
// ^^^^^^^^^^^^^^^^^^ | ||
// [analyzer] unspecified | ||
// [cfe] unspecified | ||
|
||
sealed class SealedImplementsSealed implements TypedefSealedClass {} | ||
// ^^^^^^^^^^^^^^^^^^ | ||
// [analyzer] unspecified | ||
// [cfe] unspecified | ||
|
||
abstract class AbstractImplementsSealed implements TypedefSealedClass {} | ||
// ^^^^^^^^^^^^^^^^^^ | ||
// [analyzer] unspecified | ||
// [cfe] unspecified | ||
|
||
abstract base class AbstractBaseImplementsSealed implements TypedefSealedClass {} | ||
// ^^^^^^^^^^^^^^^^^^ | ||
// [analyzer] unspecified | ||
// [cfe] unspecified | ||
|
||
abstract interface class AbstractInterfaceImplementsSealed implements TypedefSealedClass {} | ||
// ^^^^^^^^^^^^^^^^^^ | ||
// [analyzer] unspecified | ||
// [cfe] unspecified | ||
|
||
abstract final class AbstractFinalImplementsSealed implements TypedefSealedClass {} | ||
// ^^^^^^^^^^^^^^^^^^ | ||
// [analyzer] unspecified | ||
// [cfe] unspecified | ||
|
||
mixin class MixinClassImplementsSealed implements TypedefSealedClass {} | ||
// ^^^^^^^^^^^^^^^^^^ | ||
// [analyzer] unspecified | ||
// [cfe] unspecified | ||
|
||
base mixin class BaseMixinClassImplementsSealed implements TypedefSealedClass {} | ||
// ^^^^^^^^^^^^^^^^^^ | ||
// [analyzer] unspecified | ||
// [cfe] unspecified | ||
|
||
abstract mixin class AbstractMixinImplementsSealed implements TypedefSealedClass {} | ||
// ^^^^^^^^^^^^^^^^^^ | ||
// [analyzer] unspecified | ||
// [cfe] unspecified | ||
|
||
abstract base mixin class AbstractBaseMixinImplementsSealed implements TypedefSealedClass {} | ||
// ^^^^^^^^^^^^^^^^^^ | ||
// [analyzer] unspecified | ||
// [cfe] unspecified | ||
|
||
mixin MixinImplementsSealed implements TypedefSealedClass {} | ||
// ^^^^^^^^^^^^^^^^^^ | ||
// [analyzer] unspecified | ||
// [cfe] unspecified | ||
|
||
base mixin BaseMixinImplementsSealed implements TypedefSealedClass {} | ||
// ^^^^^^^^^^^^^^^^^^ | ||
// [analyzer] unspecified | ||
// [cfe] unspecified | ||
|
||
enum EnumImplementsSealedClass implements TypedefSealedClass {e1, e2} | ||
// ^^^^^^^^^^^^^^^^^^ | ||
// [analyzer] unspecified | ||
// [cfe] unspecified | ||
|
||
typedef LocalTypedefSealedClass = SealedClass; | ||
|
||
class ImplementsLocalTypedefSealedClass implements LocalTypedefSealedClass {} | ||
// ^^^^^^^^^^^^^^^^^^^^^^^ | ||
// [analyzer] unspecified | ||
// [cfe] unspecified | ||
|
||
main() { | ||
print(ImplementsSealed); | ||
print(AbstractImplementsSealed); | ||
print(AbstractBaseImplementsSealed); | ||
print(AbstractInterfaceImplementsSealed); | ||
print(AbstractFinalImplementsSealed); | ||
print(FinalImplementsSealed); | ||
print(BaseImplementsSealed); | ||
print(SealedImplementsSealed); | ||
print(InterfaceImplementsSealed); | ||
print(MixinClassImplementsSealed); | ||
print(BaseMixinClassImplementsSealed); | ||
print(AbstractMixinImplementsSealed); | ||
print(AbstractBaseMixinImplementsSealed); | ||
print(MixinImplementsSealed); | ||
print(BaseMixinImplementsSealed); | ||
print(EnumImplementsSealedClass); | ||
print(ImplementsLocalTypedefSealedClass); | ||
} |
103 changes: 103 additions & 0 deletions
103
LanguageFeatures/Class-modifiers/basic_restrictions_A01_t11.dart
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,103 @@ | ||
// 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. | ||
|
||
/// @assertion It is a compile-time error if: | ||
/// - A declaration depends directly on a sealed declaration from another | ||
/// library. | ||
/// | ||
/// @description Check that it is a compile-time error to mix in or use in the | ||
/// `on` clause of a mixin a class marked `sealed` outside of the library where | ||
/// it is declared. Test type aliases | ||
/// @author [email protected] | ||
// SharedOptions=--enable-experiment=class-modifiers | ||
|
||
import "class_modifiers_lib.dart"; | ||
|
||
mixin MixinOnSealed on TypedefSealedClass {} | ||
// ^^^^^^^^^^^^^^^^^^ | ||
// [analyzer] unspecified | ||
// [cfe] unspecified | ||
|
||
base mixin BaseMixinOnSealed on TypedefSealedClass {} | ||
// ^^^^^^^^^^^^^^^^^^ | ||
// [analyzer] unspecified | ||
// [cfe] unspecified | ||
|
||
class ClassWithSealed with TypedefSealedClass {} | ||
// ^^^^^^^^^^^^^^^^^^ | ||
// [analyzer] unspecified | ||
// [cfe] unspecified | ||
|
||
base class BaseClassWithSealed with TypedefSealedClass {} | ||
// ^^^^^^^^^^^^^^^^^^ | ||
// [analyzer] unspecified | ||
// [cfe] unspecified | ||
|
||
interface class InterfaceClassWithSealed with TypedefSealedClass {} | ||
// ^^^^^^^^^^^^^^^^^^ | ||
// [analyzer] unspecified | ||
// [cfe] unspecified | ||
|
||
final class FinalClassWithSealed with TypedefSealedClass {} | ||
// ^^^^^^^^^^^^^^^^^^ | ||
// [analyzer] unspecified | ||
// [cfe] unspecified | ||
|
||
sealed class SealedClassWithSealed with TypedefSealedClass {} | ||
// ^^^^^^^^^^^^^^^^^^ | ||
// [analyzer] unspecified | ||
// [cfe] unspecified | ||
|
||
abstract class AbstractClassWithSealed with TypedefSealedClass {} | ||
// ^^^^^^^^^^^^^^^^^^ | ||
// [analyzer] unspecified | ||
// [cfe] unspecified | ||
|
||
abstract base class AbstractBaseClassWithSealed with TypedefSealedClass {} | ||
// ^^^^^^^^^^^^^^^^^^ | ||
// [analyzer] unspecified | ||
// [cfe] unspecified | ||
|
||
abstract interface class AbstractInterfaceClassWithSealed with TypedefSealedClass {} | ||
// ^^^^^^^^^^^^^^^^^^ | ||
// [analyzer] unspecified | ||
// [cfe] unspecified | ||
|
||
abstract final class AbstractFinalClassWithSealed with TypedefSealedClass {} | ||
// ^^^^^^^^^^^^^^^^^^ | ||
// [analyzer] unspecified | ||
// [cfe] unspecified | ||
|
||
enum EnumWithSealedClass with TypedefSealedClass {e1, e2} | ||
// ^^^^^^^^^^^^^^^^^^ | ||
// [analyzer] unspecified | ||
// [cfe] unspecified | ||
|
||
typedef LocalTypedefSealedClass = SealedClass; | ||
|
||
mixin MixinOnLocalTypedefSealedClasson LocalTypedefSealedClass {} | ||
// ^^^^^^^^^^^^^^^^^^^^^^^ | ||
// [analyzer] unspecified | ||
// [cfe] unspecified | ||
|
||
class ClassWithLocalTypedefSealedClass with LocalTypedefSealedClass {} | ||
// ^^^^^^^^^^^^^^^^^^^^^^^ | ||
// [analyzer] unspecified | ||
// [cfe] unspecified | ||
|
||
main() { | ||
print(MixinOnSealed); | ||
print(BaseMixinOnSealed); | ||
print(ClassWithSealed); | ||
print(BaseClassWithSealed); | ||
print(InterfaceClassWithSealed); | ||
print(FinalClassWithSealed); | ||
print(SealedClassWithSealed); | ||
print(AbstractClassWithSealed); | ||
print(AbstractBaseClassWithSealed); | ||
print(AbstractInterfaceClassWithSealed); | ||
print(AbstractFinalClassWithSealed); | ||
print(EnumWithSealedClass); | ||
} |
Oops, something went wrong.