Skip to content

Commit

Permalink
dart-lang#2641. Add tests for multiple top-level declarations named _
Browse files Browse the repository at this point in the history
  • Loading branch information
sgrekhov committed May 15, 2024
1 parent 176226f commit dd0fbe8
Show file tree
Hide file tree
Showing 13 changed files with 883 additions and 1 deletion.
2 changes: 1 addition & 1 deletion LanguageFeatures/Wildcards/binding_A02_t07.dart
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ extension Ext on A {
class MA = Object with M;

main() {
void localFunction<_, _, _ extends num>() => "localFunction";
String localFunction<_, _, _ extends num>() => "localFunction";

var functionExpression = <_, _, _ extends num>() => "functionExpression";

Expand Down
75 changes: 75 additions & 0 deletions LanguageFeatures/Wildcards/unchanged_A04_t01.dart
Original file line number Diff line number Diff line change
@@ -0,0 +1,75 @@
// 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 Other declarations: top-level variables, top-level function
/// names, type names, member names, etc. are unchanged. They can be named `_`
/// as they are today.
///
/// @description Checks that any top-level declaration named `_` is a
/// compile-time error if there is an earlier declaration of a top-level
/// variable named `_`.
/// @author sgrekhov22@gmail.com
// SharedOptions=--enable-experiment=wildcard-variables

var _;

int _ = 1;
// ^
// [analyzer] unspecified
// [cfe] unspecified

const _ = 1;
// ^
// [analyzer] unspecified
// [cfe] unspecified

int _() => 42;
// ^
// [analyzer] unspecified
// [cfe] unspecified

int get _ => 42;
// ^
// [analyzer] unspecified
// [cfe] unspecified

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

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

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

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

class A {}
extension _ on A {}
// ^
// [analyzer] unspecified
// [cfe] unspecified

typedef _ = A;
// ^
// [analyzer] unspecified
// [cfe] unspecified

typedef void _();
// ^
// [analyzer] unspecified
// [cfe] unspecified

main() {
}
75 changes: 75 additions & 0 deletions LanguageFeatures/Wildcards/unchanged_A04_t02.dart
Original file line number Diff line number Diff line change
@@ -0,0 +1,75 @@
// 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 Other declarations: top-level variables, top-level function
/// names, type names, member names, etc. are unchanged. They can be named `_`
/// as they are today.
///
/// @description Checks that any top-level declaration named `_` is a
/// compile-time error if there is an earlier declaration of a top-level
/// constant named `_`.
/// @author sgrekhov22@gmail.com
// SharedOptions=--enable-experiment=wildcard-variables

const _ = 42;

int _ = 1;
// ^
// [analyzer] unspecified
// [cfe] unspecified

const _ = 1;
// ^
// [analyzer] unspecified
// [cfe] unspecified

int _() => 42;
// ^
// [analyzer] unspecified
// [cfe] unspecified

int get _ => 42;
// ^
// [analyzer] unspecified
// [cfe] unspecified

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

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

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

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

class A {}
extension _ on A {}
// ^
// [analyzer] unspecified
// [cfe] unspecified

typedef _ = A;
// ^
// [analyzer] unspecified
// [cfe] unspecified

typedef void _();
// ^
// [analyzer] unspecified
// [cfe] unspecified

main() {
}
75 changes: 75 additions & 0 deletions LanguageFeatures/Wildcards/unchanged_A04_t03.dart
Original file line number Diff line number Diff line change
@@ -0,0 +1,75 @@
// 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 Other declarations: top-level variables, top-level function
/// names, type names, member names, etc. are unchanged. They can be named `_`
/// as they are today.
///
/// @description Checks that any top-level declaration named `_` is a
/// compile-time error if there is an earlier declaration of a top-level
/// function named `_`.
/// @author sgrekhov22@gmail.com
// SharedOptions=--enable-experiment=wildcard-variables

void _() {}

int _ = 1;
// ^
// [analyzer] unspecified
// [cfe] unspecified

const _ = 1;
// ^
// [analyzer] unspecified
// [cfe] unspecified

int _() => 42;
// ^
// [analyzer] unspecified
// [cfe] unspecified

int get _ => 42;
// ^
// [analyzer] unspecified
// [cfe] unspecified

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

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

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

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

class A {}
extension _ on A {}
// ^
// [analyzer] unspecified
// [cfe] unspecified

typedef _ = A;
// ^
// [analyzer] unspecified
// [cfe] unspecified

typedef void _();
// ^
// [analyzer] unspecified
// [cfe] unspecified

main() {
}
75 changes: 75 additions & 0 deletions LanguageFeatures/Wildcards/unchanged_A04_t04.dart
Original file line number Diff line number Diff line change
@@ -0,0 +1,75 @@
// 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 Other declarations: top-level variables, top-level function
/// names, type names, member names, etc. are unchanged. They can be named `_`
/// as they are today.
///
/// @description Checks that any top-level declaration named `_` is a
/// compile-time error if there is an earlier declaration of a top-level
/// getter named `_`.
/// @author sgrekhov22@gmail.com
// SharedOptions=--enable-experiment=wildcard-variables

int get _ => 0;

int _ = 1;
// ^
// [analyzer] unspecified
// [cfe] unspecified

const _ = 1;
// ^
// [analyzer] unspecified
// [cfe] unspecified

int _() => 42;
// ^
// [analyzer] unspecified
// [cfe] unspecified

int get _ => 42;
// ^
// [analyzer] unspecified
// [cfe] unspecified

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

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

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

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

class A {}
extension _ on A {}
// ^
// [analyzer] unspecified
// [cfe] unspecified

typedef _ = A;
// ^
// [analyzer] unspecified
// [cfe] unspecified

typedef void _();
// ^
// [analyzer] unspecified
// [cfe] unspecified

main() {
}
74 changes: 74 additions & 0 deletions LanguageFeatures/Wildcards/unchanged_A04_t05.dart
Original file line number Diff line number Diff line change
@@ -0,0 +1,74 @@
// 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 Other declarations: top-level variables, top-level function
/// names, type names, member names, etc. are unchanged. They can be named `_`
/// as they are today.
///
/// @description Checks that any top-level declaration named `_` is a
/// compile-time error if there is an earlier declaration of a class named `_`.
/// @author sgrekhov22@gmail.com
// SharedOptions=--enable-experiment=wildcard-variables

class _ {}

int _ = 1;
// ^
// [analyzer] unspecified
// [cfe] unspecified

const _ = 1;
// ^
// [analyzer] unspecified
// [cfe] unspecified

int _() => 42;
// ^
// [analyzer] unspecified
// [cfe] unspecified

int get _ => 42;
// ^
// [analyzer] unspecified
// [cfe] unspecified

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

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

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

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

class A {}
extension _ on A {}
// ^
// [analyzer] unspecified
// [cfe] unspecified

typedef _ = A;
// ^
// [analyzer] unspecified
// [cfe] unspecified

typedef void _();
// ^
// [analyzer] unspecified
// [cfe] unspecified

main() {
}

0 comments on commit dd0fbe8

Please sign in to comment.