Skip to content

Commit

Permalink
dart-lang#2548. Add out and inout to built-in identifiers tests
Browse files Browse the repository at this point in the history
  • Loading branch information
sgrekhov committed Feb 21, 2024
1 parent 867d139 commit 61b842e
Show file tree
Hide file tree
Showing 12 changed files with 356 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
/// `inout` is used as the declared name of a class, mixin or enum.
/// @author [email protected]
// SharedOptions=--enable-experiment=variance

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

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

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

main() {
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
// 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
/// `inout` is used as the declared name of a type variable.
/// @author [email protected]
// SharedOptions=--enable-experiment=variance

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

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

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

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

main() {
print(C);
print(M);
print(E);
print(foo);
}
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
/// `inout` is used as the declared name of a type alias.
/// @author [email protected]
// SharedOptions=--enable-experiment=variance

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

typedef inout = 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
/// `inout` is used as the declared name of a prefix.
/// @author [email protected]
// SharedOptions=--enable-experiment=variance

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

main() {
inout.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
/// `inout` is used as the name of an extension.
/// @author [email protected]
// SharedOptions=--enable-experiment=variance

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

main() {
}
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 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
/// `inout` is used as the name, type parameter or alias of an extension
/// type
/// @author [email protected]
// SharedOptions=--enable-experiment=inline-class,variance

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

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

extension type ET(int _) {}

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

main() {
}
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
/// `out` is used as the declared name of a class, mixin or enum.
/// @author [email protected]
// SharedOptions=--enable-experiment=variance

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

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

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

main() {
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
// 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
/// `out` is used as the declared name of a type variable.
/// @author [email protected]
// SharedOptions=--enable-experiment=variance

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

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

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

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

main() {
print(C);
print(M);
print(E);
print(foo);
}
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
/// `out` is used as the declared name of a type alias.
/// @author [email protected]
// SharedOptions=--enable-experiment=variance

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

typedef out = 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
/// `out` is used as the declared name of a prefix.
/// @author [email protected]
// SharedOptions=--enable-experiment=variance

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

main() {
out.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
/// `out` is used as the name of an extension.
/// @author [email protected]
// SharedOptions=--enable-experiment=variance

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

main() {
}
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 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
/// `out` is used as the name, type parameter or alias of an extension
/// type
/// @author [email protected]
// SharedOptions=--enable-experiment=inline-class,variance

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

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

extension type ET(int _) {}

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

main() {
}

0 comments on commit 61b842e

Please sign in to comment.