Skip to content

Commit 7e6f7d8

Browse files
pqCommit Queue
authored and
Commit Queue
committed
[wildcards] support for CONFLICTING_TYPE_VARIABLE_AND_MEMBER_CLASS
Fixes: #56397 (This test is just representative. Coverage is supplied by the language and co19 tests.) Newly passing tests: language/wildcard_variables/declarations/class_generic_type_parameter_test language/wildcard_variables/declarations/class_member_test language/wildcard_variables/initializing_formal_parameters/this_test Change-Id: I656a70bf9315051de5c7bfb1ee34e46ba0b25032 Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/379506 Commit-Queue: Phil Quitslund <[email protected]> Reviewed-by: Brian Wilkerson <[email protected]>
1 parent d12bf71 commit 7e6f7d8

File tree

2 files changed

+27
-0
lines changed

2 files changed

+27
-0
lines changed

pkg/analyzer/lib/src/generated/error_verifier.dart

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2534,6 +2534,8 @@ class ErrorVerifier extends RecursiveAstVisitor<void>
25342534
void _checkForConflictingClassTypeVariableErrorCodes() {
25352535
var enclosingClass = _enclosingClass!;
25362536
for (TypeParameterElement typeParameter in enclosingClass.typeParameters) {
2537+
if (typeParameter.isWildcardVariable) continue;
2538+
25372539
String name = typeParameter.name;
25382540
// name is same as the name of the enclosing class
25392541
if (enclosingClass.name == name) {

pkg/analyzer/test/src/diagnostics/conflicting_type_variable_and_member_test.dart

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -75,6 +75,31 @@ class A<T> {
7575
]);
7676
}
7777

78+
test_method_wildcard() async {
79+
await assertErrorsInCode(r'''
80+
class A<_> {
81+
_() {}
82+
}
83+
''', [
84+
error(WarningCode.UNUSED_ELEMENT, 15, 1),
85+
]);
86+
}
87+
88+
test_method_wildcard_preWildcards() async {
89+
await assertErrorsInCode(r'''
90+
// @dart = 3.4
91+
// (pre wildcard-variables)
92+
93+
class A<_> {
94+
_() {}
95+
}
96+
''', [
97+
error(CompileTimeErrorCode.CONFLICTING_TYPE_VARIABLE_AND_MEMBER_CLASS, 52,
98+
1),
99+
error(WarningCode.UNUSED_ELEMENT, 59, 1),
100+
]);
101+
}
102+
78103
test_setter() async {
79104
await assertErrorsInCode(r'''
80105
class A<T> {

0 commit comments

Comments
 (0)