Skip to content

Commit

Permalink
dart-lang#1959. Tests for class modifiers restrictions and type aliases
Browse files Browse the repository at this point in the history
  • Loading branch information
sgrekhov committed Apr 26, 2023
1 parent fc31789 commit 7bb5f61
Show file tree
Hide file tree
Showing 18 changed files with 1,717 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -70,6 +70,11 @@ abstract final class AbstractFinalClassWithSealed with SealedClass {}
// [analyzer] unspecified
// [cfe] unspecified

enum EnumWithSealedClass with SealedClass {e1, e2}
// ^^^^^^^^^^^
// [analyzer] unspecified
// [cfe] unspecified

main() {
print(MixinOnSealed);
print(BaseMixinOnSealed);
Expand All @@ -81,4 +86,6 @@ main() {
print(AbstractClassWithSealed);
print(AbstractBaseClassWithSealed);
print(AbstractInterfaceClassWithSealed);
print(AbstractFinalClassWithSealed);
print(EnumWithSealedClass);
}
80 changes: 80 additions & 0 deletions LanguageFeatures/Class-modifiers/basic_restrictions_A01_t09.dart
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 LanguageFeatures/Class-modifiers/basic_restrictions_A01_t10.dart
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 LanguageFeatures/Class-modifiers/basic_restrictions_A01_t11.dart
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);
}
Loading

0 comments on commit 7bb5f61

Please sign in to comment.