Skip to content

Commit 26722fc

Browse files
pqCommit Queue
authored and
Commit Queue
committed
[wildcards] fix type parameter scope
Addresses a bunch of INVALID_ASSIGNMENT errors reported in the language and co19 tests. CompileTimeError -> Pass (expected Pass) language/wildcard_variables/non_binding/class_members_test language/wildcard_variables/non_binding/top_level_function_test language/wildcard_variables/non_binding/top_level_variable_test MissingCompileTimeError -> Pass (expected Pass) co19/LanguageFeatures/Wildcards/binding_A01_t08 co19/LanguageFeatures/Wildcards/binding_A01_t09 See: #55680 Change-Id: Ide4c3f3729a91d478be7a7e46477164e17703435 Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/379442 Reviewed-by: Brian Wilkerson <[email protected]> Commit-Queue: Phil Quitslund <[email protected]>
1 parent 7e6f7d8 commit 26722fc

File tree

2 files changed

+17
-1
lines changed

2 files changed

+17
-1
lines changed

pkg/analyzer/lib/src/dart/element/scope.dart

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -604,7 +604,11 @@ class TypeParameterScope extends EnclosedScope {
604604
super.parent,
605605
List<TypeParameterElement> elements,
606606
) {
607-
elements.forEach(_addGetter);
607+
for (var element in elements) {
608+
if (!element.isWildcardVariable) {
609+
_addGetter(element);
610+
}
611+
}
608612
}
609613
}
610614

pkg/analyzer/test/src/dart/resolution/generic_function_type_test.dart

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -153,6 +153,18 @@ class C {
153153
return (_) {};
154154
}
155155
}
156+
''');
157+
}
158+
159+
test_typeParameter_classScope_wildcards() async {
160+
await assertNoErrorsInCode(r'''
161+
class C {
162+
int _ = 0;
163+
164+
void m<_, _>() {
165+
int _ = _;
166+
}
167+
}
156168
''');
157169
}
158170
}

0 commit comments

Comments
 (0)