Skip to content

Commit

Permalink
Guard against an NPE in completion code (issue 36788)
Browse files Browse the repository at this point in the history
Change-Id: I05fc48ac7ad495820c5e3f7efdb6db2096108e54
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/107306
Reviewed-by: Konstantin Shcheglov <[email protected]>
Commit-Queue: Brian Wilkerson <[email protected]>
  • Loading branch information
bwilkerson authored and [email protected] committed Jun 25, 2019
1 parent 89e2118 commit ea0e48a
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -234,7 +234,7 @@ class _LocalVisitor extends LocalDeclarationVisitor {
_addLocalSuggestion_includeTypeNameSuggestions(
declaration.documentationComment,
declaration.name,
declaration.functionType.returnType,
declaration.functionType?.returnType,
protocol.ElementKind.FUNCTION_TYPE_ALIAS,
isAbstract: true,
isDeprecated: isDeprecated(declaration));
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2921,6 +2921,17 @@ main() {
assertSuggestFunctionTypeAlias('F', 'void');
}

test_functionTypeAlias_genericTypeAlias_incomplete() async {
addTestSource(r'''
typedef F = int;
main() {
^
}
''');
await computeSuggestions();
assertSuggestFunctionTypeAlias('F', 'dynamic');
}

test_functionTypeAlias_old() async {
addTestSource(r'''
typedef void F();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -131,7 +131,7 @@ abstract class LocalDeclarationVisitor extends GeneralizingAstVisitor {
_visitTypeParameters(declaration, declaration.typeParameters);
_visitTypeParameters(
declaration.functionType,
declaration.functionType.typeParameters,
declaration.functionType?.typeParameters,
);
} else if (declaration is MixinDeclaration) {
declaredMixin(declaration);
Expand Down

0 comments on commit ea0e48a

Please sign in to comment.