Skip to content

Commit f8d6ad7

Browse files
DanTupCommit Queue
authored andcommitted
[analysis_server] Don't generate inline values inside function types
We shouldn't treat parameter names inside function types as if they are references to other parameters/variables of that name. Fixes #61099 Change-Id: Iadc97723a87af1ddbbde618d1c9c8e5b51499a6f Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/440160 Commit-Queue: Keerti Parthasarathy <[email protected]> Reviewed-by: Keerti Parthasarathy <[email protected]> Reviewed-by: Brian Wilkerson <[email protected]>
1 parent 5e64657 commit f8d6ad7

File tree

2 files changed

+20
-0
lines changed

2 files changed

+20
-0
lines changed

pkg/analysis_server/lib/src/lsp/handlers/handler_inline_value.dart

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -335,6 +335,12 @@ class _InlineValueVisitor extends GeneralizingAstVisitor<void> {
335335
super.visitFunctionExpression(node);
336336
}
337337

338+
@override
339+
void visitGenericFunctionType(GenericFunctionType node) {
340+
// Don't descent into function types or we may generate values
341+
// for their parameters.
342+
}
343+
338344
@override
339345
void visitPrefixedIdentifier(PrefixedIdentifier node) {
340346
if (experimentalInlineValuesProperties) {

pkg/analysis_server/test/lsp/inline_value_test.dart

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -120,6 +120,20 @@ void f(List list1, List<int> /*[0*/list2/*0]*/, Iterable iterable1, Iterable ite
120120
await verify_values(code, ofType: InlineValueVariableLookup);
121121
}
122122

123+
Future<void> test_parameter_nestedInFunctionType() async {
124+
// A parameter nested inside a function type should not produce a value.
125+
code = TestCode.parse(r'''
126+
void f(
127+
int /*[0*/value/*0]*/, {
128+
required void Function(int value) /*[1*/func/*1]*/,
129+
}) {
130+
^
131+
}
132+
''');
133+
134+
await verify_values(code, ofType: InlineValueVariableLookup);
135+
}
136+
123137
Future<void> test_parameter_read() async {
124138
code = TestCode.parse(r'''
125139
void f(int aaa, int bbb) {

0 commit comments

Comments
 (0)