Skip to content

Commit 4480ea6

Browse files
FMorschelCommit Queue
authored andcommitted
[DAS] Fixes void completion on for in iterable position
Bug: #61134 Change-Id: I5ce02226f705e5bce5148494d81435c9eb96aad4 Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/443631 Commit-Queue: Konstantin Shcheglov <[email protected]> Reviewed-by: Konstantin Shcheglov <[email protected]> Auto-Submit: Felipe Morschel <[email protected]> Commit-Queue: Brian Wilkerson <[email protected]> Reviewed-by: Brian Wilkerson <[email protected]>
1 parent 16a4386 commit 4480ea6

File tree

2 files changed

+20
-2
lines changed

2 files changed

+20
-2
lines changed

pkg/analysis_server/lib/src/services/completion/dart/in_scope_completion_pass.dart

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4153,6 +4153,7 @@ class InScopeCompletionPass extends SimpleAstVisitor<void> {
41534153
keywordHelper.addKeyword(Keyword.AWAIT);
41544154
declarationHelper(
41554155
mustBeStatic: node.inStaticContext,
4156+
mustBeNonVoid: true,
41564157
).addLexicalDeclarations(node);
41574158
}
41584159
}

pkg/analysis_server/test/services/completion/dart/location/for_statement_test.dart

Lines changed: 19 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -46,8 +46,8 @@ suggestions
4646

4747
Future<void> test_afterIn() async {
4848
await computeSuggestions('''
49-
void f(List<(int, int)> x01) {
50-
for (final (a, b) in ^)
49+
void f(List<int> x01) {
50+
for (final a in ^)
5151
}
5252
''');
5353
assertResponse(r'''
@@ -59,6 +59,23 @@ suggestions
5959
''');
6060
}
6161

62+
Future<void> test_afterIn_notVoid() async {
63+
await computeSuggestions('''
64+
void f(List<int> x01) {
65+
for (final a in ^)
66+
}
67+
68+
void f01() {}
69+
''');
70+
assertResponse(r'''
71+
suggestions
72+
x01
73+
kind: parameter
74+
await
75+
kind: keyword
76+
''');
77+
}
78+
6279
Future<void> test_afterPattern() async {
6380
await computeSuggestions('''
6481
void f(Object x) {

0 commit comments

Comments
 (0)