mirror of
https://github.com/dart-lang/sdk
synced 2024-09-16 03:17:55 +00:00
Don't attempt to record reference to a named parameter of a synthetic function.
R=brianwilkerson@google.com, paulberry@google.com BUG= Review URL: https://codereview.chromium.org/2537883002 .
This commit is contained in:
parent
636e7b559b
commit
86866a3116
|
@ -440,6 +440,13 @@ class _IndexContributor extends GeneralizingAstVisitor {
|
|||
false) {
|
||||
return;
|
||||
}
|
||||
// Ignore named parameters of synthetic functions, e.g. created for LUB.
|
||||
// These functions are not bound to a source, we cannot index them.
|
||||
if (elementKind == ElementKind.PARAMETER &&
|
||||
element is ParameterElement &&
|
||||
element.enclosingElement.isSynthetic) {
|
||||
return;
|
||||
}
|
||||
// Add the relation.
|
||||
assembler.addElementRelation(element, kind, offset, length, isQualified);
|
||||
}
|
||||
|
|
|
@ -814,6 +814,18 @@ main() {
|
|||
assertThat(element)..isReferencedAt('p: 1', true);
|
||||
}
|
||||
|
||||
test_isReferencedBy_synthetic_leastUpperBound() async {
|
||||
await _indexTestUnit('''
|
||||
int f1({int p}) => 1;
|
||||
int f2({int p}) => 2;
|
||||
main(bool b) {
|
||||
var f = b ? f1 : f2;
|
||||
f(p: 0);
|
||||
}''');
|
||||
// We should not crash because of reference to "p" - a named parameter
|
||||
// of a synthetic LUB FunctionElement created for "f".
|
||||
}
|
||||
|
||||
test_isReferencedBy_TopLevelVariableElement() async {
|
||||
provider.newFile(
|
||||
_p('$testProject/lib.dart'),
|
||||
|
|
Loading…
Reference in a new issue