Skip to content

Commit

Permalink
Fix the type of (after-first) named parameter in ArgumentList.
Browse files Browse the repository at this point in the history
Fixes #48514
Fixes #48310

Change-Id: I6cab8052a91a51a4c44470e5be81b78ef68e56cc
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/242281
Reviewed-by: Brian Wilkerson <[email protected]>
Commit-Queue: Brian Wilkerson <[email protected]>
  • Loading branch information
asashour authored and Commit Bot committed Apr 23, 2022
1 parent 1bdec73 commit 3428b44
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -540,10 +540,12 @@ class _ContextTypeVisitor extends SimpleAstVisitor<DartType> {
if (offset <= argument.offset) {
return typeOfIndexPositionalParameter();
}
if (argument.contains(offset) && offset >= argument.name.end) {
return argument.staticParameterElement?.type;
if (argument.contains(offset)) {
if (offset >= argument.name.end) {
return argument.staticParameterElement?.type;
}
return null;
}
return null;
} else {
if (previousArgument == null || previousArgument.end < offset) {
if (offset <= argument.end) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -109,6 +109,16 @@ void f(C c) {
''', 'int');
}

Future<void> test_argumentList_named_second() async {
await assertContextType('''
void f({String p1, int p2}) {}
void g() {
f(p1: '', p2: ^);
}
''', 'int');
}

Future<void> test_argumentList_named_unresolved_hasNamedParameters() async {
await assertContextType('''
void f({int i}) {}
Expand Down

0 comments on commit 3428b44

Please sign in to comment.