-
Notifications
You must be signed in to change notification settings - Fork 28
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
#2641. Check that it is still an error to declare more than one mixin…
… member named `_` (#2672) Check that it is still an error to declare more than one mixin member named `_`
- Loading branch information
Showing
8 changed files
with
1,150 additions
and
0 deletions.
There are no files selected for viewing
175 changes: 175 additions & 0 deletions
175
LanguageFeatures/Wildcards/other_declarations_A05_t14.dart
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,175 @@ | ||
// 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 it is a compile-time error to declare more than one | ||
/// member named `_`. Test a static variable vs other mixin members conflict. | ||
/// @author sgrekhov22@gmail.com | ||
// SharedOptions=--enable-experiment=wildcard-variables | ||
|
||
class ContainsWildcardVariable { | ||
int _ = 0; | ||
} | ||
|
||
class ContainsWildcardMethod { | ||
int _() => 0; | ||
} | ||
|
||
class ContainsWildcardGetter { | ||
int get _ => 0; | ||
} | ||
|
||
class ContainsWildcardSetter { | ||
void set _(int v) {} | ||
} | ||
|
||
mixin M1 { | ||
static int _ = 1; | ||
static int _ = 1; | ||
// ^ | ||
// [analyzer] unspecified | ||
// [cfe] unspecified | ||
} | ||
|
||
mixin M2 { | ||
static int _ = 1; | ||
static int _() => 2; | ||
// ^ | ||
// [analyzer] unspecified | ||
// [cfe] unspecified | ||
} | ||
|
||
mixin M3 { | ||
static int _ = 1; | ||
static int get _ => 3; | ||
// ^ | ||
// [analyzer] unspecified | ||
// [cfe] unspecified | ||
} | ||
|
||
mixin M4 { | ||
static int _ = 1; | ||
// ^ | ||
// [cfe] unspecified | ||
static void set _(int v) {} | ||
// ^ | ||
// [analyzer] unspecified | ||
// [cfe] unspecified | ||
} | ||
|
||
mixin M5 { | ||
static int _ = 1; | ||
// ^ | ||
// [analyzer] unspecified | ||
int _ = 5; | ||
// ^ | ||
// [cfe] unspecified | ||
} | ||
|
||
mixin M5On on ContainsWildcardVariable { | ||
static int _ = 1; | ||
// ^ | ||
// [analyzer] unspecified | ||
// [cfe] unspecified | ||
} | ||
|
||
mixin M5Implements implements ContainsWildcardVariable { | ||
static int _ = 1; | ||
// ^ | ||
// [analyzer] unspecified | ||
// [cfe] unspecified | ||
} | ||
|
||
mixin M6 { | ||
static int _ = 1; | ||
// ^ | ||
// [analyzer] unspecified | ||
int _() => 6; | ||
// ^ | ||
// [cfe] unspecified | ||
} | ||
|
||
mixin M6On on ContainsWildcardMethod { | ||
static int _ = 1; | ||
// ^ | ||
// [analyzer] unspecified | ||
// [cfe] unspecified | ||
} | ||
|
||
mixin M6Implements implements ContainsWildcardMethod { | ||
static int _ = 1; | ||
// ^ | ||
// [analyzer] unspecified | ||
// [cfe] unspecified | ||
} | ||
|
||
mixin M7 { | ||
static int _ = 1; | ||
// ^ | ||
// [analyzer] unspecified | ||
int get _ => 7; | ||
// ^ | ||
// [cfe] unspecified | ||
} | ||
|
||
mixin M7On on ContainsWildcardGetter { | ||
static int _ = 1; | ||
// ^ | ||
// [analyzer] unspecified | ||
// [cfe] unspecified | ||
} | ||
|
||
mixin M7Implements implements ContainsWildcardGetter { | ||
static int _ = 1; | ||
// ^ | ||
// [analyzer] unspecified | ||
// [cfe] unspecified | ||
} | ||
|
||
mixin M8 { | ||
static int _ = 1; | ||
// ^ | ||
// [analyzer] unspecified | ||
// [cfe] unspecified | ||
void set _(int v) {} | ||
// ^ | ||
// [cfe] unspecified | ||
} | ||
|
||
mixin M8On on ContainsWildcardSetter { | ||
static int _ = 1; | ||
// ^ | ||
// [analyzer] unspecified | ||
// [cfe] unspecified | ||
} | ||
|
||
mixin M8Implements implements ContainsWildcardSetter { | ||
static int _ = 1; | ||
// ^ | ||
// [analyzer] unspecified | ||
// [cfe] unspecified | ||
} | ||
|
||
main() { | ||
print(M1); | ||
print(M2); | ||
print(M3); | ||
print(M4); | ||
print(M5); | ||
print(M5On); | ||
print(M5Implements); | ||
print(M6); | ||
print(M6On); | ||
print(M6Implements); | ||
print(M7); | ||
print(M7On); | ||
print(M7Implements); | ||
print(M8); | ||
print(M8On); | ||
print(M8Implements); | ||
} |
168 changes: 168 additions & 0 deletions
168
LanguageFeatures/Wildcards/other_declarations_A05_t15.dart
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,168 @@ | ||
// 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 it is a compile-time error to declare more than one | ||
/// member named `_`. Test a static getter vs other mixin members conflict. | ||
/// @author sgrekhov22@gmail.com | ||
// SharedOptions=--enable-experiment=wildcard-variables | ||
|
||
class ContainsWildcardVariable { | ||
int _ = 0; | ||
} | ||
|
||
class ContainsWildcardMethod { | ||
int _() => 0; | ||
} | ||
|
||
class ContainsWildcardGetter { | ||
int get _ => 0; | ||
} | ||
|
||
class ContainsWildcardSetter { | ||
void set _(int v) {} | ||
} | ||
|
||
mixin M1 { | ||
static int get _ => 1; | ||
static int _ = 1; | ||
// ^ | ||
// [analyzer] unspecified | ||
// [cfe] unspecified | ||
} | ||
|
||
mixin M2 { | ||
static int get _ => 1; | ||
static int _() => 2; | ||
// ^ | ||
// [analyzer] unspecified | ||
// [cfe] unspecified | ||
} | ||
|
||
mixin M3 { | ||
static int get _ => 1; | ||
static int get _ => 3; | ||
// ^ | ||
// [analyzer] unspecified | ||
// [cfe] unspecified | ||
} | ||
|
||
mixin M4 { | ||
static int get _ => 1; | ||
static void set _(int v) {} // Ok | ||
} | ||
|
||
mixin M5 { | ||
static int get _ => 1; | ||
// ^ | ||
// [analyzer] unspecified | ||
int _ = 5; | ||
// ^ | ||
// [cfe] unspecified | ||
} | ||
|
||
mixin M5On on ContainsWildcardVariable { | ||
static int get _ => 1; | ||
// ^ | ||
// [analyzer] unspecified | ||
// [cfe] unspecified | ||
} | ||
|
||
mixin M5Implements implements ContainsWildcardVariable { | ||
static int get _ => 1; | ||
// ^ | ||
// [analyzer] unspecified | ||
// [cfe] unspecified | ||
} | ||
|
||
mixin M6 { | ||
static int get _ => 1; | ||
// ^ | ||
// [analyzer] unspecified | ||
int _() => 6; | ||
// ^ | ||
// [cfe] unspecified | ||
} | ||
|
||
mixin M6On on ContainsWildcardMethod { | ||
static int get _ => 1; | ||
// ^ | ||
// [analyzer] unspecified | ||
// [cfe] unspecified | ||
} | ||
|
||
mixin M6Implements implements ContainsWildcardMethod { | ||
static int get _ => 1; | ||
// ^ | ||
// [analyzer] unspecified | ||
// [cfe] unspecified | ||
} | ||
|
||
mixin M7 { | ||
static int get _ => 1; | ||
// ^ | ||
// [analyzer] unspecified | ||
int get _ => 7; | ||
// ^ | ||
// [cfe] unspecified | ||
} | ||
|
||
mixin M7On on ContainsWildcardGetter { | ||
static int get _ => 1; | ||
// ^ | ||
// [analyzer] unspecified | ||
// [cfe] unspecified | ||
} | ||
|
||
mixin M7Implements implements ContainsWildcardGetter { | ||
static int get _ => 1; | ||
// ^ | ||
// [analyzer] unspecified | ||
// [cfe] unspecified | ||
} | ||
|
||
mixin M8 { | ||
static int get _ => 1; | ||
// ^ | ||
// [analyzer] unspecified | ||
// [cfe] unspecified | ||
void set _(int v) {} | ||
} | ||
|
||
mixin M8On on ContainsWildcardSetter { | ||
static int get _ => 1; | ||
// ^ | ||
// [analyzer] unspecified | ||
// [cfe] unspecified | ||
} | ||
|
||
mixin M8Implements implements ContainsWildcardSetter { | ||
static int get _ => 1; | ||
// ^ | ||
// [analyzer] unspecified | ||
// [cfe] unspecified | ||
} | ||
|
||
main() { | ||
print(M1); | ||
print(M2); | ||
print(M3); | ||
print(M4); | ||
print(M5); | ||
print(M5On); | ||
print(M5Implements); | ||
print(M6); | ||
print(M6On); | ||
print(M6Implements); | ||
print(M7); | ||
print(M7On); | ||
print(M7Implements); | ||
print(M8); | ||
print(M8On); | ||
print(M8Implements); | ||
} |
Oops, something went wrong.