[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 https://github.com/dart-lang/sdk/issues/61099

Change-Id: Iadc97723a87af1ddbbde618d1c9c8e5b51499a6f
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/440160
Commit-Queue: Keerti Parthasarathy <keertip@google.com>
Reviewed-by: Keerti Parthasarathy <keertip@google.com>
Reviewed-by: Brian Wilkerson <brianwilkerson@google.com>
This commit is contained in:
Danny Tuppeny
2025-07-14 08:16:00 -07:00
committed by Commit Queue
parent 5e646575b1
commit f8d6ad7e4b
2 changed files with 20 additions and 0 deletions
@@ -335,6 +335,12 @@ class _InlineValueVisitor extends GeneralizingAstVisitor<void> {
super.visitFunctionExpression(node);
}
@override
void visitGenericFunctionType(GenericFunctionType node) {
// Don't descent into function types or we may generate values
// for their parameters.
}
@override
void visitPrefixedIdentifier(PrefixedIdentifier node) {
if (experimentalInlineValuesProperties) {
@@ -120,6 +120,20 @@ void f(List list1, List<int> /*[0*/list2/*0]*/, Iterable iterable1, Iterable ite
await verify_values(code, ofType: InlineValueVariableLookup);
}
Future<void> test_parameter_nestedInFunctionType() async {
// A parameter nested inside a function type should not produce a value.
code = TestCode.parse(r'''
void f(
int /*[0*/value/*0]*/, {
required void Function(int value) /*[1*/func/*1]*/,
}) {
^
}
''');
await verify_values(code, ofType: InlineValueVariableLookup);
}
Future<void> test_parameter_read() async {
code = TestCode.parse(r'''
void f(int aaa, int bbb) {