Skip to content

Commit fd26223

Browse files
jensjohaCommit Queue
authored andcommitted
[kernel] Scope calculator filters out wildcard variables
Fixes #60841. Change-Id: Id1fd9300ad241af879ca7dfff3e4bf61125af852 Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/433720 Reviewed-by: Johnni Winther <[email protected]> Commit-Queue: Jens Johansen <[email protected]>
1 parent 81b0326 commit fd26223

File tree

2 files changed

+8
-2
lines changed

2 files changed

+8
-2
lines changed

pkg/kernel/lib/dart_scope_calculator.dart

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -160,7 +160,9 @@ class DartScopeBuilder extends VisitorDefault<void> with VisitorVoidMixin {
160160
//
161161
// A null name signals that the variable was synthetically introduced by the
162162
// compiler so they are skipped.
163-
if ((decl.fileOffset < 0 || decl.fileOffset < _offset) && name != null) {
163+
if ((decl.fileOffset < 0 || decl.fileOffset < _offset) &&
164+
!decl.isWildcard &&
165+
name != null) {
164166
_definitions[name] = decl.type;
165167
}
166168
super.visitVariableDeclaration(decl);
@@ -289,7 +291,8 @@ class DartScopeBuilder2 extends VisitorDefault<void> with VisitorVoidMixin {
289291
String? name = decl.name;
290292
if (name != null &&
291293
!decl.isSynthesized &&
292-
!hoistedUnwritten.contains(decl)) {
294+
!hoistedUnwritten.contains(decl) &&
295+
!decl.isWildcard) {
293296
definitions[name] = decl;
294297
}
295298
}

pkg/kernel/test/dart_scope_calculator_test.dart

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -360,6 +360,9 @@ class ScopeTestingBinaryPrinter extends BinaryPrinter {
360360
if (variable.isHoisted && !setVariables.contains(variable)) {
361361
// A hoisted variable that isn't set (yet) --- pretend it isn't
362362
// there.
363+
} else if (variable.isWildcard) {
364+
// A wildcard variable doesn't really exist so we'll ignore it,
365+
// see https://github.com/dart-lang/sdk/issues/60841.
363366
} else {
364367
expectedVariablesMap[name] = variable.type;
365368
}

0 commit comments

Comments
 (0)