blob: 7b3788d57a3c473e062f55d37d6549d9e1b5bddb [file] [log] [blame]
// 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 A local declaration whose name is `_` does not bind that name to
/// anything.
///
/// @description Checks that no entry named `_` is introduced into the enclosing
/// scope by a wildcarded declaration. Test parameters of functions and methods.
/// @author sgrekhov22@gmail.com
// SharedOptions=--enable-experiment=wildcard-variables
void topLevelFunction1(int _) {
print(_);
// ^
// [analyzer] unspecified
// [cfe] unspecified
}
void topLevelFunction2([int _ = 1]) {
print(_);
// ^
// [analyzer] unspecified
// [cfe] unspecified
}
class C {
static void staticMethod1(int _) {
print(_);
// ^
// [analyzer] unspecified
// [cfe] unspecified
}
static void staticMethod2([int _ = 2]) {
print(_);
// ^
// [analyzer] unspecified
// [cfe] unspecified
}
void instanceMethod1(int _) {
print(_);
// ^
// [analyzer] unspecified
// [cfe] unspecified
}
void instanceMethod2([int _ = 3]) {
print(_);
// ^
// [analyzer] unspecified
// [cfe] unspecified
}
}
mixin M {
static void staticMethod1(int _) {
print(_);
// ^
// [analyzer] unspecified
// [cfe] unspecified
}
static void staticMethod2([int _ = 4]) {
print(_);
// ^
// [analyzer] unspecified
// [cfe] unspecified
}
void instanceMethod1(int _) {
print(_);
// ^
// [analyzer] unspecified
// [cfe] unspecified
}
void instanceMethod2([int _ = 5]) {
print(_);
// ^
// [analyzer] unspecified
// [cfe] unspecified
}
}
enum E {
e1;
static void staticMethod1(int _) {
print(_);
// ^
// [analyzer] unspecified
// [cfe] unspecified
}
static void staticMethod2([int _ = 6]) {
print(_);
// ^
// [analyzer] unspecified
// [cfe] unspecified
}
void instanceMethod1(int _) {
print(_);
// ^
// [analyzer] unspecified
// [cfe] unspecified
}
void instanceMethod2([int _ = 7]) {
print(_);
// ^
// [analyzer] unspecified
// [cfe] unspecified
}
}
extension type ET(int id) {
static void staticMethod1(int _) {
print(_);
// ^
// [analyzer] unspecified
// [cfe] unspecified
}
static void staticMethod2([int _ = 8]) {
print(_);
// ^
// [analyzer] unspecified
// [cfe] unspecified
}
void instanceMethod1(int _) {
print(_);
// ^
// [analyzer] unspecified
// [cfe] unspecified
}
void instanceMethod2([int _ = 9]) {
print(_);
// ^
// [analyzer] unspecified
// [cfe] unspecified
}
}
class A {}
extension Ext on A {
static void staticMethod1(int _) {
print(_);
// ^
// [analyzer] unspecified
// [cfe] unspecified
}
static void staticMethod2([int _ = 10]) {
print(_);
// ^
// [analyzer] unspecified
// [cfe] unspecified
}
void instanceMethod1(int _) {
print(_);
// ^
// [analyzer] unspecified
// [cfe] unspecified
}
void instanceMethod2([int _ = 11]) {
print(_);
// ^
// [analyzer] unspecified
// [cfe] unspecified
}
}
main() {
void localFunction1(int _) {
print(_);
// ^
// [analyzer] unspecified
// [cfe] unspecified
}
void localFunction2([int _ = 12]) {
print(_);
// ^
// [analyzer] unspecified
// [cfe] unspecified
}
var functionExpression1 = (int _) {
print(_);
// ^
// [analyzer] unspecified
// [cfe] unspecified
};
var functionExpression2 = ([int _ = 13]) {
print(_);
// ^
// [analyzer] unspecified
// [cfe] unspecified
};
print(topLevelFunction1);
print(topLevelFunction2);
print(localFunction1);
print(localFunction2);
print(functionExpression1);
print(functionExpression2);
print(C);
print(M);
print(E);
print(ET);
print(A);
}