Skip to content

Commit

Permalink
#2559. Add more augmented expression tests for class-like declarations (
Browse files Browse the repository at this point in the history
#3019)

Add more augmented expression tests for class-like declarations
  • Loading branch information
sgrekhov authored Dec 19, 2024
1 parent dbba013 commit c433852
Show file tree
Hide file tree
Showing 6 changed files with 290 additions and 0 deletions.
Original file line number Diff line number Diff line change
@@ -0,0 +1,58 @@
// Copyright (c) 2024, 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 Consider a non-augmenting member declaration Dm that occurs
/// inside an augmenting type declaration Dt. A compile-time error occurs if the
/// identifier `augmented` occurs in Dm.
///
/// @description Checks that it is a compile-time error if an augmenting
/// class-like declaration has a type parameter named `augmented`.
/// @author [email protected]
// SharedOptions=--enable-experiment=macros

class C<augmented> {}

augment class C<augmented> {}
// ^^^^^^^^^
// [analyzer] unspecified
// [cfe] unspecified

mixin M<augmented> {}

augment class M<augmented> {}
// ^^^^^^^^^
// [analyzer] unspecified
// [cfe] unspecified

enum E<augmented> {e0;}

augment enum E<augmented> {e1;}
// ^^^^^^^^^
// [analyzer] unspecified
// [cfe] unspecified

class A {}

extension Ext<augmented> on A {}

augment extension Ext<augmented> {}
// ^^^^^^^^^
// [analyzer] unspecified
// [cfe] unspecified

extension type ET<augmented>(int _) {}

augment extension type ET<augmented> {}
// ^^^^^^^^^
// [analyzer] unspecified
// [cfe] unspecified

main() {
print(C);
print(M);
print(E);
print(A);
print(ET);
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,61 @@
// Copyright (c) 2024, 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 Consider a non-augmenting member declaration Dm that occurs
/// inside an augmenting type declaration Dt. A compile-time error occurs if the
/// identifier `augmented` occurs in Dm.
///
/// @description Checks that it is a compile-time error if an augmenting
/// class-like declaration has a type parameter with a type bound named
/// `augmented`.
/// @author [email protected]
// SharedOptions=--enable-experiment=macros

class augmented {}

class C<T extends augmented> {}

augment class C<T extends augmented> {}
// ^^^^^^^^^
// [analyzer] unspecified
// [cfe] unspecified

mixin M<T extends augmented> {}

augment class M<T extends augmented> {}
// ^^^^^^^^^
// [analyzer] unspecified
// [cfe] unspecified

enum E<T extends augmented> {e0;}

augment enum E<T extends augmented> {e1;}
// ^^^^^^^^^
// [analyzer] unspecified
// [cfe] unspecified

class A {}

extension Ext<T extends augmented> on A {}

augment extension Ext<T extends augmented> {}
// ^^^^^^^^^
// [analyzer] unspecified
// [cfe] unspecified

extension type ET<augmented>(int _) {}

augment extension type ET<T extends augmented> {}
// ^^^^^^^^^
// [analyzer] unspecified
// [cfe] unspecified

main() {
print(C);
print(M);
print(E);
print(A);
print(ET);
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
// Copyright (c) 2024, 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 Consider a non-augmenting member declaration Dm that occurs
/// inside an augmenting type declaration Dt. A compile-time error occurs if the
/// identifier `augmented` occurs in Dm.
///
/// @description Checks that it is a compile-time error if an augmenting class
/// declaration extends a type that contains the name `augmented`.
/// @author [email protected]
// SharedOptions=--enable-experiment=macros

class augmented {}
class A<T> {}

class C1 {}

augment class C1 extends augmented {}
// ^^^^^^^^^
// [analyzer] unspecified
// [cfe] unspecified

class C2 {}

augment class C2 extends A<augmented> {}
// ^^^^^^^^^
// [analyzer] unspecified
// [cfe] unspecified

main() {
print(C1);
print(C2);
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
// Copyright (c) 2024, 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 Consider a non-augmenting member declaration Dm that occurs
/// inside an augmenting type declaration Dt. A compile-time error occurs if the
/// identifier `augmented` occurs in Dm.
///
/// @description Checks that it is a compile-time error if an augmenting mixin
/// declaration extends a type that contains the name `augmented`.
/// @author [email protected]
// SharedOptions=--enable-experiment=macros

class augmented {}
class A<T> {}

mixin M1 {}

augment mixin M1 on augmented {}
// ^^^^^^^^^
// [analyzer] unspecified
// [cfe] unspecified

mixin M2 {}

augment mixin M2 on A<augmented> {}
// ^^^^^^^^^
// [analyzer] unspecified
// [cfe] unspecified
main() {
print(M1);
print(M2);
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,50 @@
// Copyright (c) 2024, 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 Consider a non-augmenting member declaration Dm that occurs
/// inside an augmenting type declaration Dt. A compile-time error occurs if the
/// identifier `augmented` occurs in Dm.
///
/// @description Checks that it is a compile-time error if an augmenting
/// class-like declaration implements a type named `augmented`.
/// @author [email protected]
// SharedOptions=--enable-experiment=macros

interface class augmented {}
class B extends augmented {}
class C {}

augment class C implements augmented {}
// ^^^^^^^^^
// [analyzer] unspecified
// [cfe] unspecified

mixin M {}

augment mixin M implements augmented {}
// ^^^^^^^^^
// [analyzer] unspecified
// [cfe] unspecified

enum E {e0;}

augment enum E implements augmented {e1;}
// ^^^^^^^^^
// [analyzer] unspecified
// [cfe] unspecified

extension type ET(B _) {}

augment extension type ET implements augmented {}
// ^^^^^^^^^
// [analyzer] unspecified
// [cfe] unspecified

main() {
print(C);
print(M);
print(E);
print(ET);
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,52 @@
// Copyright (c) 2024, 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 Consider a non-augmenting member declaration Dm that occurs
/// inside an augmenting type declaration Dt. A compile-time error occurs if the
/// identifier `augmented` occurs in Dm.
///
/// @description Checks that it is a compile-time error if an augmenting
/// class-like declaration implements a type that contains the name `augmented`.
/// @author [email protected]
// SharedOptions=--enable-experiment=macros

interface class augmented {}
class B extends augmented {}
class A<T> {}

class C {}

augment class C implements A<augmented> {}
// ^^^^^^^^^
// [analyzer] unspecified
// [cfe] unspecified

mixin M {}

augment mixin M implements A<augmented> {}
// ^^^^^^^^^
// [analyzer] unspecified
// [cfe] unspecified

enum E {e0;}

augment enum E implements A<augmented> {e1;}
// ^^^^^^^^^
// [analyzer] unspecified
// [cfe] unspecified

extension type ET(A<B> _) {}

augment extension type ET implements A<augmented> {}
// ^^^^^^^^^
// [analyzer] unspecified
// [cfe] unspecified

main() {
print(C);
print(M);
print(E);
print(ET);
}

0 comments on commit c433852

Please sign in to comment.