Skip to content

Commit edf09b5

Browse files
scheglovCommit Queue
authored andcommitted
Issue 60495. Fix for invalid nested function typed formal parameter in generic function type.
Bug: #60495 Change-Id: Iee26bf01aba2ce55be998971ab943d125b227378 Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/421400 Reviewed-by: Paul Berry <[email protected]> Commit-Queue: Konstantin Shcheglov <[email protected]>
1 parent 569c901 commit edf09b5

File tree

2 files changed

+35
-2
lines changed

2 files changed

+35
-2
lines changed

pkg/analyzer/lib/src/summary2/element_builder.dart

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2071,9 +2071,11 @@ class _EnclosingContext {
20712071
_parameters.add(element);
20722072
if (name == null) {
20732073
return null;
2074-
} else {
2075-
return _addReference('@parameter', name, element);
20762074
}
2075+
if (fragment.reference == null) {
2076+
return null;
2077+
}
2078+
return _addReference('@parameter', name, element);
20772079
}
20782080

20792081
void addPropertyAccessorSynthetic(PropertyAccessorElementImpl element) {

pkg/analyzer/test/src/summary/elements/top_level_variable_test.dart

Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1077,6 +1077,37 @@ library
10771077
''');
10781078
}
10791079

1080+
test_variable_functionTyped_nested_invalid_functionTypedFormal() async {
1081+
var library = await buildLibrary(r'''
1082+
final int Function(int, {void fn()})? foo;
1083+
''');
1084+
checkElementText(library, r'''
1085+
library
1086+
reference: <testLibrary>
1087+
fragments
1088+
<testLibraryFragment>
1089+
element: <testLibrary>
1090+
topLevelVariables
1091+
foo @38
1092+
reference: <testLibraryFragment>::@topLevelVariable::foo
1093+
element: <testLibrary>::@topLevelVariable::foo
1094+
getter2: <testLibraryFragment>::@getter::foo
1095+
getters
1096+
synthetic get foo
1097+
reference: <testLibraryFragment>::@getter::foo
1098+
element: <testLibraryFragment>::@getter::foo#element
1099+
topLevelVariables
1100+
final foo
1101+
reference: <testLibrary>::@topLevelVariable::foo
1102+
firstFragment: <testLibraryFragment>::@topLevelVariable::foo
1103+
type: int Function(int, {void Function() fn})?
1104+
getter: <testLibraryFragment>::@getter::foo#element
1105+
getters
1106+
synthetic static get foo
1107+
firstFragment: <testLibraryFragment>::@getter::foo
1108+
''');
1109+
}
1110+
10801111
test_variable_getterInLib_setterInPart() async {
10811112
newFile('$testPackageLibPath/a.dart', '''
10821113
part of my.lib;

0 commit comments

Comments
 (0)