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. More valid combinations of modifiers tests added
- Loading branch information
Showing
78 changed files
with
2,672 additions
and
603 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
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 |
---|---|---|
|
@@ -6,13 +6,13 @@ | |
/// implemented or mixed in and is not exhaustive | ||
/// | ||
/// @description Check that it is not an error to extend an | ||
/// `abstract base class` (by `base/final/sealed`) or declare mixin `on` it, in | ||
/// the same library where it is defined | ||
/// `abstract base class` (by `base/final/sealed`) outside of the library where | ||
/// it is defined (other cases tested in `basic_restrictions_A04_t*`) | ||
/// @author [email protected] | ||
// SharedOptions=--enable-experiment=class-modifiers | ||
|
||
abstract base class AbstractBaseClass {} | ||
import "class_modifiers_lib.dart"; | ||
|
||
base class BaseClassExtendsAbstractBaseClass extends AbstractBaseClass {} | ||
|
||
|
@@ -26,13 +26,10 @@ abstract base class AbstractBaseClassExtendsAbstractBaseClass | |
abstract final class AbstractFinalClassExtendsAbstractBaseClass | ||
extends AbstractBaseClass {} | ||
|
||
base mixin BaseMixinOnAbstractBaseClass on AbstractBaseClass {} | ||
|
||
main() { | ||
print(BaseClassExtendsAbstractBaseClass); | ||
print(FinalClassExtendsAbstractBaseClass); | ||
print(SealedClassExtendsAbstractBaseClass); | ||
print(AbstractBaseClassExtendsAbstractBaseClass); | ||
print(AbstractFinalClassExtendsAbstractBaseClass); | ||
print(BaseMixinOnAbstractBaseClass); | ||
} |
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 |
---|---|---|
|
@@ -6,13 +6,13 @@ | |
/// implemented or mixed in and is not exhaustive | ||
/// | ||
/// @description Check that it is not an error to extend an | ||
/// `abstract base class` (by `base/final/sealed`) or declare mixin `on` it, | ||
/// outside of the library where it is defined | ||
/// `abstract base class` (by `base/final/sealed`) in the same library where it | ||
/// is defined (other cases tested in `basic_restrictions_A04_t*`) | ||
/// @author [email protected] | ||
// SharedOptions=--enable-experiment=class-modifiers | ||
|
||
import "class_modifiers_lib.dart"; | ||
abstract base class AbstractBaseClass {} | ||
|
||
base class BaseClassExtendsAbstractBaseClass extends AbstractBaseClass {} | ||
|
||
|
@@ -26,13 +26,10 @@ abstract base class AbstractBaseClassExtendsAbstractBaseClass | |
abstract final class AbstractFinalClassExtendsAbstractBaseClass | ||
extends AbstractBaseClass {} | ||
|
||
base mixin BaseMixinOnAbstractBaseClass on AbstractBaseClass {} | ||
|
||
main() { | ||
print(BaseClassExtendsAbstractBaseClass); | ||
print(FinalClassExtendsAbstractBaseClass); | ||
print(SealedClassExtendsAbstractBaseClass); | ||
print(AbstractBaseClassExtendsAbstractBaseClass); | ||
print(AbstractFinalClassExtendsAbstractBaseClass); | ||
print(BaseMixinOnAbstractBaseClass); | ||
} |
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 |
---|---|---|
|
@@ -5,38 +5,63 @@ | |
/// @assertion Abstract base class can be extended but not constructed, | ||
/// implemented or mixed in and is not exhaustive | ||
/// | ||
/// @description Check that it is not an error to implement an | ||
/// `abstract base class` (by `base/final/sealed`), in the same library where it | ||
/// is defined | ||
/// @description Checks that it is a compile-time error if an | ||
/// `abstract base class` is implemented outside of the library where it is | ||
/// defined by `base/final/sealed class` (other cases tested in | ||
/// `basic_restrictions_A03_t*`) | ||
/// @author [email protected] | ||
// SharedOptions=--enable-experiment=class-modifiers | ||
|
||
abstract base class AbstractBaseClass {} | ||
import "class_modifiers_lib.dart"; | ||
|
||
base class BaseClassImplementsBaseClass implements AbstractBaseClass {} | ||
base class BaseClassImplementsAbstractBaseClass implements AbstractBaseClass {} | ||
// ^^^^^^^^^^^^^^^^^ | ||
// [analyzer] unspecified | ||
// [cfe] unspecified | ||
|
||
final class FinalClassImplementsBaseClass implements AbstractBaseClass {} | ||
final class FinalClassImplementsAbstractBaseClass implements AbstractBaseClass {} | ||
// ^^^^^^^^^^^^^^^^^ | ||
// [analyzer] unspecified | ||
// [cfe] unspecified | ||
|
||
sealed class SealedClassImplementsBaseClass implements AbstractBaseClass {} | ||
sealed class SealedClassImplementsAbstractBaseClass implements AbstractBaseClass {} | ||
// ^^^^^^^^^^^^^^^^^ | ||
// [analyzer] unspecified | ||
// [cfe] unspecified | ||
|
||
abstract base class AbstractBaseClassImplementsBaseClass | ||
implements AbstractBaseClass {} | ||
abstract base class AbstractBaseClassImplementsAbstractBaseClass implements AbstractBaseClass {} | ||
// ^^^^^^^^^^^^^^^^^ | ||
// [analyzer] unspecified | ||
// [cfe] unspecified | ||
|
||
abstract final class AbstractFinalClassImplementsBaseClass | ||
implements AbstractBaseClass {} | ||
abstract final class AbstractFinalClassImplementsAbstractBaseClass implements AbstractBaseClass {} | ||
// ^^^^^^^^^^^^^^^^^ | ||
// [analyzer] unspecified | ||
// [cfe] unspecified | ||
|
||
base mixin class BaseMixinOnAbstractBaseClass implements AbstractBaseClass {} | ||
base mixin class BaseMixinImplementsAbstractBaseClass implements AbstractBaseClass {} | ||
// ^^^^^^^^^^^^^^^^^ | ||
// [analyzer] unspecified | ||
// [cfe] unspecified | ||
|
||
abstract base mixin class AbstractBaseMixinOnAbstractBaseClass | ||
implements AbstractBaseClass {} | ||
abstract base mixin class AbstractBaseMixinImplementsAbstractBaseClass implements AbstractBaseClass {} | ||
// ^^^^^^^^^^^^^^^^^ | ||
// [analyzer] unspecified | ||
// [cfe] unspecified | ||
|
||
enum EnumImplementsAbstractBaseClass implements AbstractBaseClass {e1, e2} | ||
// ^^^^^^^^^^^^^^^^^ | ||
// [analyzer] unspecified | ||
// [cfe] unspecified | ||
|
||
main() { | ||
print(BaseClassImplementsBaseClass); | ||
print(FinalClassImplementsBaseClass); | ||
print(SealedClassImplementsBaseClass); | ||
print(AbstractBaseClassImplementsBaseClass); | ||
print(AbstractFinalClassImplementsBaseClass); | ||
print(BaseMixinOnAbstractBaseClass); | ||
print(AbstractBaseMixinOnAbstractBaseClass); | ||
print(BaseClassImplementsAbstractBaseClass); | ||
print(FinalClassImplementsAbstractBaseClass); | ||
print(SealedClassImplementsAbstractBaseClass); | ||
print(AbstractBaseClassImplementsAbstractBaseClass); | ||
print(AbstractFinalClassImplementsAbstractBaseClass); | ||
print(BaseMixinImplementsAbstractBaseClass); | ||
print(AbstractBaseMixinImplementsAbstractBaseClass); | ||
print(EnumImplementsAbstractBaseClass); | ||
} |
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 |
---|---|---|
|
@@ -5,56 +5,42 @@ | |
/// @assertion Abstract base class can be extended but not constructed, | ||
/// implemented or mixed in and is not exhaustive | ||
/// | ||
/// @description Checks that it is a compile-time error if an | ||
/// `abstract base class` is implemented outside of the library where it is | ||
/// defined | ||
/// @description Check that it is not an error to implement an | ||
/// `abstract base class` (by `base/final/sealed`), in the same library where it | ||
/// is defined (other cases tested in `basic_restrictions_A03_t*`) | ||
/// @author [email protected] | ||
// SharedOptions=--enable-experiment=class-modifiers | ||
|
||
import "class_modifiers_lib.dart"; | ||
abstract base class AbstractBaseClass {} | ||
|
||
base class BaseClassImplementsAbstractBaseClass implements AbstractBaseClass {} | ||
// ^^^^^^^^^^^^^^^^^ | ||
// [analyzer] unspecified | ||
// [cfe] unspecified | ||
base class BaseClassImplementsBaseClass implements AbstractBaseClass {} | ||
|
||
final class FinalClassImplementsAbstractBaseClass implements AbstractBaseClass {} | ||
// ^^^^^^^^^^^^^^^^^ | ||
// [analyzer] unspecified | ||
// [cfe] unspecified | ||
final class FinalClassImplementsBaseClass implements AbstractBaseClass {} | ||
|
||
sealed class SealedClassImplementsAbstractBaseClass implements AbstractBaseClass {} | ||
// ^^^^^^^^^^^^^^^^^ | ||
// [analyzer] unspecified | ||
// [cfe] unspecified | ||
sealed class SealedClassImplementsBaseClass implements AbstractBaseClass {} | ||
|
||
abstract base class AbstractBaseClassImplementsAbstractBaseClass implements AbstractBaseClass {} | ||
// ^^^^^^^^^^^^^^^^^ | ||
// [analyzer] unspecified | ||
// [cfe] unspecified | ||
abstract base class AbstractBaseClassImplementsBaseClass | ||
implements AbstractBaseClass {} | ||
|
||
abstract final class AbstractFinalClassImplementsAbstractBaseClass implements AbstractBaseClass {} | ||
// ^^^^^^^^^^^^^^^^^ | ||
// [analyzer] unspecified | ||
// [cfe] unspecified | ||
abstract final class AbstractFinalClassImplementsBaseClass | ||
implements AbstractBaseClass {} | ||
|
||
base mixin class BaseMixinOnAbstractBaseClass implements AbstractBaseClass {} | ||
// ^^^^^^^^^^^^^^^^^ | ||
// [analyzer] unspecified | ||
// [cfe] unspecified | ||
base mixin class BaseMixinImplementsAbstractBaseClass | ||
implements AbstractBaseClass {} | ||
|
||
abstract base mixin class AbstractBaseMixinOnAbstractBaseClass implements AbstractBaseClass {} | ||
// ^^^^^^^^^^^^^^^^^ | ||
// [analyzer] unspecified | ||
// [cfe] unspecified | ||
abstract base mixin class AbstractBaseMixinImplementsAbstractBaseClass | ||
implements AbstractBaseClass {} | ||
|
||
enum EnumImplementsAbstractBaseClass implements AbstractBaseClass { e1, e2 } | ||
|
||
main() { | ||
print(BaseClassImplementsAbstractBaseClass); | ||
print(FinalClassImplementsAbstractBaseClass); | ||
print(SealedClassImplementsAbstractBaseClass); | ||
print(AbstractBaseClassImplementsAbstractBaseClass); | ||
print(AbstractFinalClassImplementsAbstractBaseClass); | ||
print(BaseMixinOnAbstractBaseClass); | ||
print(AbstractBaseMixinOnAbstractBaseClass); | ||
print(BaseClassImplementsBaseClass); | ||
print(FinalClassImplementsBaseClass); | ||
print(SealedClassImplementsBaseClass); | ||
print(AbstractBaseClassImplementsBaseClass); | ||
print(AbstractFinalClassImplementsBaseClass); | ||
print(BaseMixinImplementsAbstractBaseClass); | ||
print(AbstractBaseMixinImplementsAbstractBaseClass); | ||
print(EnumImplementsAbstractBaseClass); | ||
} |
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 |
---|---|---|
|
@@ -6,12 +6,14 @@ | |
/// implemented or mixed in and is not exhaustive | ||
/// | ||
/// @description Checks that it is a compile-time error if an | ||
/// `abstract base class` is mixed in in the same library where it is defined | ||
/// `abstract base class` is mixed in a `base/final/sealed` class (other cases | ||
/// tested in `basic_restrictions_A04_t*`) outside of the library where it is | ||
/// defined | ||
/// @author [email protected] | ||
// SharedOptions=--enable-experiment=class-modifiers | ||
|
||
abstract base class AbstractBaseClass {} | ||
import "class_modifiers_lib.dart"; | ||
|
||
base class BaseClassWithAbstractBaseClass1 with AbstractBaseClass {} | ||
// ^^^^^^^^^^^^^^^^^ | ||
|
@@ -63,6 +65,11 @@ abstract final class AbstractFinalClassWithAbstractBaseClass2 = Object with Abst | |
// [analyzer] unspecified | ||
// [cfe] unspecified | ||
|
||
enum EnumWithAbstractBaseClass with AbstractBaseClass {e1, e2} | ||
// ^^^^^^^^^^^^^^^^^ | ||
// [analyzer] unspecified | ||
// [cfe] unspecified | ||
|
||
main() { | ||
print(BaseClassWithAbstractBaseClass1); | ||
print(BaseClassWithAbstractBaseClass2); | ||
|
@@ -74,4 +81,5 @@ main() { | |
print(AbstractBaseClassWithAbstractBaseClass2); | ||
print(AbstractFinalClassWithAbstractBaseClass1); | ||
print(AbstractFinalClassWithAbstractBaseClass2); | ||
print(EnumWithAbstractBaseClass); | ||
} |
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 |
---|---|---|
|
@@ -6,12 +6,14 @@ | |
/// implemented or mixed in and is not exhaustive | ||
/// | ||
/// @description Checks that it is a compile-time error if an | ||
/// `abstract base class` is mixed in outside of the library where it is defined | ||
/// `abstract base class` is mixed in a `base/final/sealed` class (other cases | ||
/// tested in `basic_restrictions_A04_t*`) in the same library where it is | ||
// defined | ||
/// @author [email protected] | ||
// SharedOptions=--enable-experiment=class-modifiers | ||
|
||
import "class_modifiers_lib.dart"; | ||
abstract base class AbstractBaseClass {} | ||
|
||
base class BaseClassWithAbstractBaseClass1 with AbstractBaseClass {} | ||
// ^^^^^^^^^^^^^^^^^ | ||
|
@@ -63,6 +65,11 @@ abstract final class AbstractFinalClassWithAbstractBaseClass2 = Object with Abst | |
// [analyzer] unspecified | ||
// [cfe] unspecified | ||
|
||
enum EnumWithAbstractBaseClass with AbstractBaseClass {e1, e2} | ||
// ^^^^^^^^^^^^^^^^^ | ||
// [analyzer] unspecified | ||
// [cfe] unspecified | ||
|
||
main() { | ||
print(BaseClassWithAbstractBaseClass1); | ||
print(BaseClassWithAbstractBaseClass2); | ||
|
@@ -74,4 +81,5 @@ main() { | |
print(AbstractBaseClassWithAbstractBaseClass2); | ||
print(AbstractFinalClassWithAbstractBaseClass1); | ||
print(AbstractFinalClassWithAbstractBaseClass2); | ||
print(EnumWithAbstractBaseClass); | ||
} |
25 changes: 25 additions & 0 deletions
25
LanguageFeatures/Class-modifiers/syntax_abstract_base_class_A05_t01.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,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. | ||
|
||
/// @assertion Abstract base class can be extended but not constructed, | ||
/// implemented or mixed in and is not exhaustive | ||
/// | ||
/// @description Check that it is not an error to declare a `base mixin` on an | ||
/// `abstract base class` | ||
/// @author [email protected] | ||
// SharedOptions=--enable-experiment=class-modifiers | ||
|
||
import "class_modifiers_lib.dart"; | ||
|
||
abstract base class LocalAbstractBaseClass {} | ||
|
||
base mixin BaseMixinOnAbstractBaseClass on AbstractBaseClass {} | ||
|
||
base mixin BaseMixinOnLocalAbstractBaseClass on LocalAbstractBaseClass {} | ||
|
||
main() { | ||
print(BaseMixinOnAbstractBaseClass); | ||
print(BaseMixinOnLocalAbstractBaseClass); | ||
} |
38 changes: 38 additions & 0 deletions
38
LanguageFeatures/Class-modifiers/syntax_abstract_base_class_A06_t01.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,38 @@ | ||
// 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 Abstract class can be extended and implemented but not | ||
/// constructed, mixed in and is not exhaustive | ||
/// | ||
/// @description Checks that `abstract base class` is not exhaustive | ||
/// @author [email protected] | ||
// SharedOptions=--enable-experiment=class-modifiers | ||
|
||
import "class_modifiers_lib.dart"; | ||
|
||
abstract base class _C {} | ||
base class ExtendsC1 extends _C {} | ||
base class ExtendsC2 extends _C {} | ||
|
||
String test1(_C c) => switch (c) { | ||
// ^^^^^^ | ||
// [analyzer] unspecified | ||
// [cfe] unspecified | ||
ExtendsC1 _ => "ExtendsC1", | ||
ExtendsC2 _ => "ExtendsC2" | ||
}; | ||
|
||
String test2(AbstractBaseClass c) => switch (c) { | ||
// ^^^^^^ | ||
// [analyzer] unspecified | ||
// [cfe] unspecified | ||
ExtendsAbstractClass1 _ => "ExtendsAbstractClass1", | ||
ExtendsAbstractClass2 _ => "ExtendsAbstractClass2" | ||
}; | ||
|
||
main() { | ||
test1(ExtendsC1()); | ||
test2(BaseClassExtendsAbstractBaseClass1()); | ||
} |
Oops, something went wrong.