Skip to content

#1959. Tests for class modifiers restrictions and type aliases #2030

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 5 commits into from
May 10, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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);
}
105 changes: 105 additions & 0 deletions LanguageFeatures/Class-modifiers/basic_restrictions_A01_t11.dart
Original file line number Diff line number Diff line change
@@ -0,0 +1,105 @@
// 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 MixinOnLocalTypedefSealedClass on 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);
print(MixinOnLocalTypedefSealedClass);
print(ClassWithLocalTypedefSealedClass);
}
Loading