@@ -42,6 +42,7 @@ import 'package:analyzer/src/generated/utilities_collection.dart';
4242import 'package:analyzer/src/generated/utilities_dart.dart' ;
4343import 'package:analyzer/src/generated/utilities_general.dart' ;
4444import 'package:analyzer/src/summary/idl.dart' ;
45+ import 'package:analyzer/src/summary2/lazy_ast.dart' ;
4546import 'package:analyzer/src/summary2/linked_unit_context.dart' ;
4647import 'package:analyzer/src/summary2/reference.dart' ;
4748import 'package:analyzer/src/util/comment.dart' ;
@@ -500,6 +501,7 @@ class ClassElementImpl extends AbstractClassElementImpl
500501
501502 if (linkedNode != null ) {
502503 if (linkedNode is ClassOrMixinDeclaration ) {
504+ LazyAst .applyResolution (linkedNode);
503505 _createPropertiesAndAccessors ();
504506 assert (_accessors != null );
505507 return _accessors;
@@ -544,6 +546,7 @@ class ClassElementImpl extends AbstractClassElementImpl
544546 }
545547
546548 if (linkedNode != null ) {
549+ LazyAst .applyResolution (linkedNode);
547550 var context = enclosingUnit.linkedContext;
548551 var containerRef = reference.getChild ('@constructor' );
549552 _constructors = context.getConstructors (linkedNode).map ((node) {
@@ -605,6 +608,7 @@ class ClassElementImpl extends AbstractClassElementImpl
605608
606609 if (linkedNode != null ) {
607610 if (linkedNode is ClassOrMixinDeclaration ) {
611+ LazyAst .applyResolution (linkedNode);
608612 _createPropertiesAndAccessors ();
609613 assert (_fields != null );
610614 return _fields;
@@ -705,6 +709,7 @@ class ClassElementImpl extends AbstractClassElementImpl
705709 }
706710
707711 if (linkedNode != null ) {
712+ LazyAst .applyResolution (linkedNode);
708713 var context = enclosingUnit.linkedContext;
709714 var implementsClause = context.getImplementsClause (linkedNode);
710715 if (implementsClause != null ) {
@@ -780,6 +785,7 @@ class ClassElementImpl extends AbstractClassElementImpl
780785 }
781786
782787 if (linkedNode != null ) {
788+ LazyAst .applyResolution (linkedNode);
783789 var context = enclosingUnit.linkedContext;
784790 var containerRef = reference.getChild ('@method' );
785791 return _methods = context
@@ -816,6 +822,7 @@ class ClassElementImpl extends AbstractClassElementImpl
816822 }
817823
818824 if (linkedNode != null ) {
825+ LazyAst .applyResolution (linkedNode);
819826 var context = enclosingUnit.linkedContext;
820827 var withClause = context.getWithClause (linkedNode);
821828 if (withClause != null ) {
@@ -865,7 +872,18 @@ class ClassElementImpl extends AbstractClassElementImpl
865872 }
866873
867874 if (linkedNode != null ) {
868- var type = linkedContext.getSuperclass (linkedNode)? .type;
875+ var node = linkedNode;
876+ LazyAst .applyResolution (node);
877+
878+ DartType type;
879+ if (node is ClassDeclaration ) {
880+ type = node.extendsClause? .superclass? .type;
881+ } else if (node is ClassTypeAlias ) {
882+ type = linkedContext.getSuperclass (linkedNode)? .type;
883+ } else {
884+ throw UnimplementedError ('${node .runtimeType }' );
885+ }
886+
869887 if (_isInterfaceTypeClass (type)) {
870888 return _supertype = type;
871889 }
@@ -1964,9 +1982,9 @@ class ConstructorElementImpl extends ExecutableElementImpl
19641982 if (_constantInitializers != null ) return _constantInitializers;
19651983
19661984 if (linkedNode != null ) {
1967- return _constantInitializers = linkedContext. getConstructorInitializers (
1968- linkedNode,
1969- ) ;
1985+ var node = linkedNode as ConstructorDeclaration ;
1986+ LazyAst . applyResolution (node);
1987+ return _constantInitializers = node.initializers ;
19701988 }
19711989
19721990 return _constantInitializers;
@@ -2080,13 +2098,13 @@ class ConstructorElementImpl extends ExecutableElementImpl
20802098 if (_redirectedConstructor != null ) return _redirectedConstructor;
20812099
20822100 if (linkedNode != null ) {
2083- var context = enclosingUnit.linkedContext;
2101+ var node = linkedNode as ConstructorDeclaration ;
2102+ LazyAst .applyResolution (node);
20842103 if (isFactory) {
2085- var node = context. getConstructorRedirected (linkedNode);
2086- return _redirectedConstructor = node? .staticElement;
2104+ return _redirectedConstructor =
2105+ node.redirectedConstructor ? .staticElement;
20872106 } else {
2088- var initializers = context.getConstructorInitializers (linkedNode);
2089- for (var initializer in initializers) {
2107+ for (var initializer in node.initializers) {
20902108 if (initializer is RedirectingConstructorInvocation ) {
20912109 return _redirectedConstructor = initializer.staticElement;
20922110 }
@@ -2214,6 +2232,7 @@ mixin ConstVariableElement implements ElementImpl, ConstantEvaluationTarget {
22142232 if (_constantInitializer != null ) return _constantInitializer;
22152233
22162234 if (linkedNode != null ) {
2235+ LazyAst .applyResolution (linkedNode);
22172236 var context = enclosingUnit.linkedContext;
22182237 return _constantInitializer = context.readInitializer (linkedNode);
22192238 }
@@ -2984,8 +3003,10 @@ abstract class ElementImpl implements Element {
29843003
29853004 @override
29863005 List <ElementAnnotation > get metadata {
3006+ if (_metadata != null ) return _metadata;
3007+
29873008 if (linkedNode != null ) {
2988- if (_metadata != null ) return _metadata ;
3009+ LazyAst . applyResolution (linkedNode) ;
29893010 var metadata = linkedContext.getMetadata (linkedNode);
29903011 return _metadata = _buildAnnotations2 (enclosingUnit, metadata);
29913012 }
@@ -3491,6 +3512,9 @@ class EnumElementImpl extends AbstractClassElementImpl {
34913512 ConstructorElement getNamedConstructor (String name) => null ;
34923513
34933514 void _resynthesizeMembers2 () {
3515+ var node = linkedNode as EnumDeclaration ;
3516+ LazyAst .applyResolution (node);
3517+
34943518 var fields = < FieldElementImpl > [];
34953519 var getters = < PropertyAccessorElementImpl > [];
34963520
@@ -3518,7 +3542,7 @@ class EnumElementImpl extends AbstractClassElementImpl {
35183542
35193543 // Build fields for all enum constants.
35203544 var containerRef = reference.getChild ('@constant' );
3521- var constants = linkedContext. getEnumConstants (linkedNode) ;
3545+ var constants = node.constants ;
35223546 for (var i = 0 ; i < constants.length; ++ i) {
35233547 var constant = constants[i];
35243548 var name = constant.name.name;
@@ -3703,6 +3727,7 @@ abstract class ExecutableElementImpl extends ElementImpl
37033727 if (_parameters != null ) return _parameters;
37043728
37053729 if (linkedNode != null ) {
3730+ LazyAst .applyResolution (linkedNode);
37063731 var context = enclosingUnit.linkedContext;
37073732 var containerRef = reference.getChild ('@parameter' );
37083733 var formalParameters = context.getFormalParameters (linkedNode);
@@ -3741,6 +3766,7 @@ abstract class ExecutableElementImpl extends ElementImpl
37413766 if (_returnType != null ) return _returnType;
37423767
37433768 if (linkedNode != null ) {
3769+ LazyAst .applyResolution (linkedNode);
37443770 var context = enclosingUnit.linkedContext;
37453771 return _returnType = context.getReturnType (linkedNode);
37463772 }
@@ -3929,6 +3955,7 @@ class ExtensionElementImpl extends ElementImpl
39293955
39303956 if (linkedNode != null ) {
39313957 if (linkedNode is ExtensionDeclaration ) {
3958+ LazyAst .applyResolution (linkedNode);
39323959 _createPropertiesAndAccessors ();
39333960 assert (_accessors != null );
39343961 return _accessors;
@@ -3988,7 +4015,9 @@ class ExtensionElementImpl extends ElementImpl
39884015 if (_extendedType != null ) return _extendedType;
39894016
39904017 if (linkedNode != null ) {
3991- return _extendedType = linkedContext.getExtendedType (linkedNode).type;
4018+ var node = linkedNode as ExtensionDeclaration ;
4019+ LazyAst .applyResolution (linkedNode);
4020+ return _extendedType = node.extendedType.type;
39924021 }
39934022
39944023 return _extendedType;
@@ -4002,6 +4031,7 @@ class ExtensionElementImpl extends ElementImpl
40024031
40034032 if (linkedNode != null ) {
40044033 if (linkedNode is ExtensionDeclaration ) {
4034+ LazyAst .applyResolution (linkedNode);
40054035 _createPropertiesAndAccessors ();
40064036 assert (_fields != null );
40074037 return _fields;
@@ -4041,6 +4071,7 @@ class ExtensionElementImpl extends ElementImpl
40414071 }
40424072
40434073 if (linkedNode != null ) {
4074+ LazyAst .applyResolution (linkedNode);
40444075 var context = enclosingUnit.linkedContext;
40454076 var containerRef = reference.getChild ('@method' );
40464077 return _methods = context
@@ -4507,14 +4538,16 @@ class FunctionTypeAliasElementImpl extends ElementImpl
45074538 if (_function != null ) return _function;
45084539
45094540 if (linkedNode != null ) {
4541+ LazyAst .applyResolution (linkedNode);
45104542 if (linkedNode is GenericTypeAlias ) {
45114543 var context = enclosingUnit.linkedContext;
45124544 var function = context.getGeneticTypeAliasFunction (linkedNode);
45134545 if (function != null ) {
4514- var reference = context.getGenericFunctionTypeReference (function);
4515- _function = reference.element;
4516- encloseElement (_function);
4517- return _function;
4546+ return _function = GenericFunctionTypeElementImpl .forLinkedNode (
4547+ this ,
4548+ reference.getChild ('@function' ),
4549+ function,
4550+ );
45184551 } else {
45194552 return _function = GenericFunctionTypeElementImpl .forOffset (- 1 )
45204553 ..typeParameters = const < TypeParameterElement > []
@@ -5839,8 +5872,10 @@ class MixinElementImpl extends ClassElementImpl {
58395872 if (_superclassConstraints != null ) return _superclassConstraints;
58405873
58415874 if (linkedNode != null ) {
5875+ var node = linkedNode as MixinDeclaration ;
5876+ LazyAst .applyResolution (node);
58425877 List <InterfaceType > constraints;
5843- var onClause = enclosingUnit.linkedContext. getOnClause (linkedNode) ;
5878+ var onClause = node.onClause ;
58445879 if (onClause != null ) {
58455880 constraints = onClause.superclassConstraints
58465881 .map ((node) => node.type)
@@ -6565,8 +6600,9 @@ class ParameterElementImpl extends VariableElementImpl
65656600
65666601 @override
65676602 DartType get typeInternal {
6603+ if (_type != null ) return _type;
6604+
65686605 if (linkedNode != null ) {
6569- if (_type != null ) return _type;
65706606 var context = enclosingUnit.linkedContext;
65716607 return _type = context.getType (linkedNode);
65726608 }
@@ -7159,6 +7195,7 @@ abstract class PropertyInducingElementImpl
71597195 DartType get typeInternal {
71607196 if (linkedNode != null ) {
71617197 if (_type != null ) return _type;
7198+ LazyAst .applyResolution (linkedNode);
71627199 _type = linkedContext.getType (linkedNode);
71637200
71647201 // While performing inference during linking, the first step is to collect
@@ -7527,13 +7564,19 @@ mixin TypeParameterizedElementMixin
75277564 if (_typeParameterElements != null ) return _typeParameterElements;
75287565
75297566 if (linkedNode != null ) {
7567+ LazyAst .applyResolution (linkedNode);
75307568 var typeParameters = linkedContext.getTypeParameters2 (linkedNode);
75317569 if (typeParameters == null ) {
75327570 return _typeParameterElements = const [];
75337571 }
75347572 var containerRef = reference.getChild ('@typeParameter' );
75357573 return _typeParameterElements =
75367574 typeParameters.typeParameters.map <TypeParameterElement >((node) {
7575+ var element = node.declaredElement;
7576+ if (element != null ) {
7577+ return element;
7578+ }
7579+
75377580 var reference = containerRef.getChild (node.name.name);
75387581 if (reference.hasElementFor (node)) {
75397582 return reference.element as TypeParameterElement ;
0 commit comments