commit | 3428b449d191d5837558faf492cd60480496ea8d | [log] [tgz] |
---|---|---|
author | Ahmed Ashour <asashour@yahoo.com> | Sat Apr 23 16:06:52 2022 +0000 |
committer | Commit Bot <commit-bot@chromium.org> | Sat Apr 23 16:06:52 2022 +0000 |
tree | 2be5590b21c8569f42b990fac3240bea0e2bb26a | |
parent | 1bdec73db6de87b570666d13eceb1a8c08ac142f [diff] |
Fix the type of (after-first) named parameter in `ArgumentList`. Fixes #48514 Fixes #48310 Change-Id: I6cab8052a91a51a4c44470e5be81b78ef68e56cc Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/242281 Reviewed-by: Brian Wilkerson <brianwilkerson@google.com> Commit-Queue: Brian Wilkerson <brianwilkerson@google.com>
diff --git a/pkg/analysis_server/lib/src/services/completion/dart/feature_computer.dart b/pkg/analysis_server/lib/src/services/completion/dart/feature_computer.dart index 983ff52..0996659 100644 --- a/pkg/analysis_server/lib/src/services/completion/dart/feature_computer.dart +++ b/pkg/analysis_server/lib/src/services/completion/dart/feature_computer.dart
@@ -540,10 +540,12 @@ 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) {
diff --git a/pkg/analysis_server/test/src/services/completion/dart/feature_computer_test.dart b/pkg/analysis_server/test/src/services/completion/dart/feature_computer_test.dart index bfa63e0..f866620 100644 --- a/pkg/analysis_server/test/src/services/completion/dart/feature_computer_test.dart +++ b/pkg/analysis_server/test/src/services/completion/dart/feature_computer_test.dart
@@ -109,6 +109,16 @@ ''', '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}) {}