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 983ff5200353..09966598d2bd 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 @@ class _ContextTypeVisitor extends SimpleAstVisitor { 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 bfa63e0343cc..f866620ec596 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 @@ void f(C c) { ''', 'int'); } + Future test_argumentList_named_second() async { + await assertContextType(''' +void f({String p1, int p2}) {} + +void g() { + f(p1: '', p2: ^); +} +''', 'int'); + } + Future test_argumentList_named_unresolved_hasNamedParameters() async { await assertContextType(''' void f({int i}) {}