Skip to content

Commit

Permalink
dart-lang#2559. Add tests checking that augment is a built-in ident…
Browse files Browse the repository at this point in the history
…ifier
  • Loading branch information
sgrekhov committed Mar 5, 2024
1 parent 3e12dd0 commit 3402776
Show file tree
Hide file tree
Showing 6 changed files with 183 additions and 0 deletions.
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
// 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 It is a syntax error if a built-in identifier is used as the
/// declared name of a prefix, class, mixin, enum, type parameter, type alias,
/// or extension.
///
/// @description Checks that it is a compile-time error if a built-in identifier
/// `augment` is used as the declared name of a class, mixin or enum.
/// @author sgrekhov22@gmail.com
// SharedOptions=--enable-experiment=macros

class augment {}
// ^^^^^^^
// [analyzer] unspecified
// [cfe] unspecified

mixin augment {}
// ^^^^^^^
// [analyzer] unspecified
// [cfe] unspecified

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

main() {
}
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 It is a syntax error if a built-in identifier is used as the
/// declared name of a prefix, class, mixin, enum, type parameter, type alias,
/// or extension.
///
/// @description Checks that it is a compile-time error if a built-in identifier
/// `augment` is used as the declared name of a type variable.
/// @author sgrekhov22@gmail.com
// SharedOptions=--enable-experiment=macros

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

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

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

void foo<augment>() {}
// ^^^^^^^
// [analyzer] unspecified
// [cfe] unspecified

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

main() {
print(C);
print(M);
print(E);
print(foo);
print(List);
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
// 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 It is a syntax error if a built-in identifier is used as the
/// declared name of a prefix, class, mixin, enum, type parameter, type alias,
/// or extension.
///
/// @description Checks that it is a compile-time error if a built-in identifier
/// `augment` is used as the declared name of a type alias.
/// @author sgrekhov22@gmail.com
// SharedOptions=--enable-experiment=macros

typedef int augment();
// ^^^^^^^
// [analyzer] unspecified
// [cfe] unspecified

typedef augment = int;
// ^^^^^^^
// [analyzer] unspecified
// [cfe] unspecified

main() {
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
// 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 It is a syntax error if a built-in identifier is used as the
/// declared name of a prefix, class, mixin, enum, type parameter, type alias,
/// or extension.
///
/// @description Checks that it is a compile-time error if a built-in identifier
/// `augment` is used as the declared name of a prefix.
/// @author sgrekhov22@gmail.com
// SharedOptions=--enable-experiment=macros

import "../lib.dart" as augment;
// ^^^^^^^
// [analyzer] unspecified
// [cfe] unspecified

main() {
augment.x;
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
// 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 It is a syntax error if a built-in identifier is used as the
/// declared name of a prefix, class, mixin, enum, type parameter, type alias,
/// or extension.
///
/// @description Checks that it is a compile-time error if a built-in identifier
/// `augment` is used as the name of an extension.
/// @author sgrekhov22@gmail.com
// SharedOptions=--enable-experiment=macros

extension augment on int {}
// ^^^^^^^
// [analyzer] unspecified
// [cfe] unspecified

main() {
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
// 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 It is a syntax error if a built-in identifier is used as the
/// declared name of a prefix, class, mixin, enum, type parameter, type alias,
/// or extension.
///
/// @description Checks that it is a compile-time error if a built-in identifier
/// `augment` is used as the name, type parameter or alias of an extension type
/// @author sgrekhov22@gmail.com
// SharedOptions=--enable-experiment=macros

extension type augment(int _) {}
// ^^^^^^^
// [analyzer] unspecified
// [cfe] unspecified

extension type ListET<augment>(List<augment> _) {}
// ^^^^^^^
// [analyzer] unspecified
// [cfe] unspecified

extension type ET(int _) {}

typedef augment = ET;
// ^^^^^^^
// [analyzer] unspecified
// [cfe] unspecified

main() {
}

0 comments on commit 3402776

Please sign in to comment.