Skip to content

Commit

Permalink
Fix for indexing FieldFormalParameterMember with unresolved field.
Browse files Browse the repository at this point in the history
R=brianwilkerson@google.com

Bug: dart-lang/sdk#38071
Change-Id: Ifa2f9218357f0f7bb3236f66aee34c8940c8b206
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/116865
Reviewed-by: Brian Wilkerson <brianwilkerson@google.com>
Commit-Queue: Konstantin Shcheglov <scheglov@google.com>
  • Loading branch information
scheglov authored and commit-bot@chromium.org committed Sep 11, 2019
1 parent d18bfb4 commit c6b0ae1
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 0 deletions.
4 changes: 4 additions & 0 deletions pkg/analyzer/lib/src/dart/element/member.dart
Original file line number Diff line number Diff line change
Expand Up @@ -251,6 +251,10 @@ class FieldFormalParameterMember extends ParameterMember
@override
FieldElement get field {
var field = (baseElement as FieldFormalParameterElement).field;
if (field == null) {
return null;
}

return FieldMember(field, _substitution);
}

Expand Down
13 changes: 13 additions & 0 deletions pkg/analyzer/test/src/dart/analysis/index_test.dart
Original file line number Diff line number Diff line change
Expand Up @@ -67,6 +67,19 @@ class IndexTest extends BaseAnalysisDriverTest {
return imports[index].importedLibrary.definingCompilationUnit;
}

test_fieldFormalParameter_noSuchField() async {
await _indexTestUnit('''
class B<T> {
B({this.x}) {}
foo() {
B<int>(x: 1);
}
}
''');
// No exceptions.
}

test_hasAncestor_ClassDeclaration() async {
await _indexTestUnit('''
class A {}
Expand Down

0 comments on commit c6b0ae1

Please sign in to comment.