The function type might be null in GenericTypeAlias.
R=brianwilkerson@google.com
Change-Id: Ia7004239b42171a20e724d80c6f0c4c60b1173f7
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/100986
Reviewed-by: Brian Wilkerson <brianwilkerson@google.com>
Commit-Queue: Konstantin Shcheglov <scheglov@google.com>
diff --git a/pkg/analyzer/lib/src/dart/element/element.dart b/pkg/analyzer/lib/src/dart/element/element.dart
index 968718a..51d515f 100644
--- a/pkg/analyzer/lib/src/dart/element/element.dart
+++ b/pkg/analyzer/lib/src/dart/element/element.dart
@@ -5574,12 +5574,16 @@
if (linkedNode is GenericTypeAlias) {
var context = enclosingUnit.linkedContext;
var function = context.getGeneticTypeAliasFunction(linkedNode);
- var reference = context.getGenericFunctionTypeReference(function);
- return _function = GenericFunctionTypeElementImpl.forLinkedNode(
- this,
- reference,
- function,
- );
+ if (function != null) {
+ var reference = context.getGenericFunctionTypeReference(function);
+ return _function = GenericFunctionTypeElementImpl.forLinkedNode(
+ this,
+ reference,
+ function,
+ );
+ } else {
+ return null;
+ }
} else {
return _function = GenericFunctionTypeElementImpl.forLinkedNode(
this,
diff --git a/pkg/analyzer/lib/src/summary2/ast_binary_writer.dart b/pkg/analyzer/lib/src/summary2/ast_binary_writer.dart
index 028ffd8..2cc58d4 100644
--- a/pkg/analyzer/lib/src/summary2/ast_binary_writer.dart
+++ b/pkg/analyzer/lib/src/summary2/ast_binary_writer.dart
@@ -667,7 +667,7 @@
LinkedNodeBuilder visitGenericTypeAlias(GenericTypeAlias node) {
var builder = LinkedNodeBuilder.genericTypeAlias(
genericTypeAlias_equals: _getToken(node.equals),
- genericTypeAlias_functionType: node.functionType.accept(this),
+ genericTypeAlias_functionType: node.functionType?.accept(this),
genericTypeAlias_typeParameters: node.typeParameters?.accept(this),
typeAlias_hasSelfReference:
LazyGenericTypeAlias.getHasSelfReference(node),
diff --git a/pkg/analyzer/lib/src/summary2/metadata_resolver.dart b/pkg/analyzer/lib/src/summary2/metadata_resolver.dart
index 562af3dd..4705ec8 100644
--- a/pkg/analyzer/lib/src/summary2/metadata_resolver.dart
+++ b/pkg/analyzer/lib/src/summary2/metadata_resolver.dart
@@ -125,7 +125,7 @@
void visitGenericTypeAlias(GenericTypeAlias node) {
node.metadata.accept(this);
node.typeParameters?.accept(this);
- node.functionType.accept(this);
+ node.functionType?.accept(this);
}
@override
diff --git a/pkg/analyzer/lib/src/summary2/reference_resolver.dart b/pkg/analyzer/lib/src/summary2/reference_resolver.dart
index 4b6dae9..74b8547 100644
--- a/pkg/analyzer/lib/src/summary2/reference_resolver.dart
+++ b/pkg/analyzer/lib/src/summary2/reference_resolver.dart
@@ -789,7 +789,7 @@
scope = TypeParameterScope(outerScope, element);
node.typeParameters?.accept(this);
- node.functionType.accept(this);
+ node.functionType?.accept(this);
nodesToBuildType.addDeclaration(node);
scope = outerScope;
diff --git a/pkg/analyzer/lib/src/summary2/simply_bounded.dart b/pkg/analyzer/lib/src/summary2/simply_bounded.dart
index cac5831..e1bbe8a 100644
--- a/pkg/analyzer/lib/src/summary2/simply_bounded.dart
+++ b/pkg/analyzer/lib/src/summary2/simply_bounded.dart
@@ -132,10 +132,15 @@
collector.visitParameters(node.parameters);
return collector.types;
} else if (node is GenericTypeAlias) {
- var collector = _TypeCollector();
- collector.addType(node.functionType.returnType);
- collector.visitParameters(node.functionType.parameters);
- return collector.types;
+ var functionType = node.functionType;
+ if (functionType != null) {
+ var collector = _TypeCollector();
+ collector.addType(functionType.returnType);
+ collector.visitParameters(functionType.parameters);
+ return collector.types;
+ } else {
+ return const <TypeAnnotation>[];
+ }
} else {
throw StateError('(${node.runtimeType}) $node');
}
diff --git a/pkg/analyzer/lib/src/summary2/type_alias.dart b/pkg/analyzer/lib/src/summary2/type_alias.dart
index 77b6876..56ed006 100644
--- a/pkg/analyzer/lib/src/summary2/type_alias.dart
+++ b/pkg/analyzer/lib/src/summary2/type_alias.dart
@@ -47,10 +47,12 @@
}
void genericTypeAlias(GenericTypeAlias node) {
- var function = node.functionType;
- _typeParameterList(function.typeParameters);
- _formalParameterList(function.parameters);
- _visit(function.returnType);
+ var functionType = node.functionType;
+ if (functionType != null) {
+ _typeParameterList(functionType.typeParameters);
+ _formalParameterList(functionType.parameters);
+ _visit(functionType.returnType);
+ }
}
void _argumentList(TypeArgumentList node) {