@@ -180,7 +180,7 @@ class ResolverVisitor extends ThrowingAstVisitor<void>
180180
181181 /// The element representing the function containing the current node, or
182182 /// `null` if the current node is not contained in a function.
183- ExecutableElement ? _enclosingFunction ;
183+ ExecutableElementImpl2 ? enclosingFunction ;
184184
185185 /// The element that can be referenced by the `augmented` expression.
186186 AugmentableElement ? enclosingAugmentation;
@@ -430,18 +430,6 @@ class ResolverVisitor extends ThrowingAstVisitor<void>
430430 /// current node is inside a function body.
431431 BodyInferenceContext ? get bodyContext => _bodyContext;
432432
433- /// Return the element representing the function containing the current node,
434- /// or `null` if the current node is not contained in a function.
435- ///
436- /// @return the element representing the function containing the current node
437- ExecutableElement ? get enclosingFunction => _enclosingFunction;
438-
439- /// Return the element representing the function containing the current node,
440- /// or `null` if the current node is not contained in a function.
441- ///
442- /// @return the element representing the function containing the current node
443- ExecutableElement2 ? get enclosingFunction2 => _enclosingFunction.asElement2;
444-
445433 @override
446434 FlowAnalysis <AstNodeImpl , StatementImpl , ExpressionImpl ,
447435 PromotableElementImpl2 , SharedTypeView > get flow => flowAnalysis.flow! ;
@@ -1314,12 +1302,12 @@ class ResolverVisitor extends ThrowingAstVisitor<void>
13141302 /// Set information about enclosing declarations.
13151303 void prepareEnclosingDeclarations ({
13161304 InterfaceElementImpl2 ? enclosingClassElement,
1317- ExecutableElement ? enclosingExecutableElement,
1305+ ExecutableElementImpl2 ? enclosingExecutableElement,
13181306 AugmentableElement ? enclosingAugmentation,
13191307 }) {
13201308 enclosingClass = enclosingClassElement;
13211309 _setupThisType ();
1322- _enclosingFunction = enclosingExecutableElement;
1310+ enclosingFunction = enclosingExecutableElement;
13231311 this .enclosingAugmentation = enclosingAugmentation;
13241312 }
13251313
@@ -2334,14 +2322,15 @@ class ResolverVisitor extends ThrowingAstVisitor<void>
23342322
23352323 @override
23362324 void visitConstructorDeclaration (covariant ConstructorDeclarationImpl node) {
2337- var element = node.declaredElement! ;
2325+ var fragment = node.declaredFragment! ;
2326+ var element = fragment.element;
23382327 var returnType = element.type.returnType;
2339- var outerFunction = _enclosingFunction ;
2328+ var outerFunction = enclosingFunction ;
23402329 var outerAugmentation = enclosingAugmentation;
23412330
23422331 try {
2343- _enclosingFunction = element;
2344- enclosingAugmentation = element ;
2332+ enclosingFunction = element;
2333+ enclosingAugmentation = fragment ;
23452334 assert (_thisType == null );
23462335 _setupThisType ();
23472336 checkUnreachableNode (node);
@@ -2369,7 +2358,7 @@ class ResolverVisitor extends ThrowingAstVisitor<void>
23692358 flowAnalysis.bodyOrInitializer_exit ();
23702359 nullSafetyDeadCodeVerifier.flowEnd (node);
23712360 } finally {
2372- _enclosingFunction = outerFunction;
2361+ enclosingFunction = outerFunction;
23732362 enclosingAugmentation = outerAugmentation;
23742363 _thisType = null ;
23752364 }
@@ -2392,7 +2381,7 @@ class ResolverVisitor extends ThrowingAstVisitor<void>
23922381 expression = popRewrite ()! ;
23932382 var whyNotPromoted = flowAnalysis.flow? .whyNotPromoted (expression);
23942383 if (fieldElement != null ) {
2395- var enclosingConstructor = enclosingFunction as ConstructorElement ;
2384+ var enclosingConstructor = enclosingFunction as ConstructorElementImpl2 ;
23962385 checkForFieldInitializerNotAssignable (node, fieldElement.asElement2,
23972386 isConstConstructor: enclosingConstructor.isConst,
23982387 whyNotPromoted: whyNotPromoted);
@@ -2792,15 +2781,16 @@ class ResolverVisitor extends ThrowingAstVisitor<void>
27922781 @override
27932782 void visitFunctionDeclaration (covariant FunctionDeclarationImpl node) {
27942783 bool isLocal = node.parent is FunctionDeclarationStatement ;
2795- var element = node.declaredElement! ;
2784+ var fragment = node.declaredFragment! ;
2785+ var element = fragment.element;
27962786 var functionType = node.declaredElement! .type;
2797- var outerFunction = _enclosingFunction ;
2787+ var outerFunction = enclosingFunction ;
27982788 var outerAugmentation = enclosingAugmentation;
27992789
28002790 try {
2801- _enclosingFunction = element;
2791+ enclosingFunction = element;
28022792 if (! isLocal) {
2803- if (element case AugmentableElement augmentation) {
2793+ if (fragment case AugmentableElement augmentation) {
28042794 enclosingAugmentation = augmentation;
28052795 }
28062796 }
@@ -2843,7 +2833,7 @@ class ResolverVisitor extends ThrowingAstVisitor<void>
28432833 }
28442834 nullSafetyDeadCodeVerifier.flowEnd (node);
28452835 } finally {
2846- _enclosingFunction = outerFunction;
2836+ enclosingFunction = outerFunction;
28472837 enclosingAugmentation = outerAugmentation;
28482838 }
28492839 }
@@ -2860,13 +2850,13 @@ class ResolverVisitor extends ThrowingAstVisitor<void>
28602850 void visitFunctionExpression (covariant FunctionExpressionImpl node,
28612851 {TypeImpl contextType = UnknownInferredType .instance}) {
28622852 inferenceLogWriter? .enterExpression (node, contextType);
2863- var outerFunction = _enclosingFunction ;
2864- _enclosingFunction = node.declaredElement ;
2853+ var outerFunction = enclosingFunction ;
2854+ enclosingFunction = node.declaredFragment ! .element ;
28652855
28662856 _functionExpressionResolver.resolve (node, contextType: contextType);
28672857 insertGenericFunctionInstantiation (node, contextType: contextType);
28682858
2869- _enclosingFunction = outerFunction;
2859+ enclosingFunction = outerFunction;
28702860 inferenceLogWriter? .exitExpression (node);
28712861 }
28722862
@@ -3197,14 +3187,15 @@ class ResolverVisitor extends ThrowingAstVisitor<void>
31973187
31983188 @override
31993189 void visitMethodDeclaration (covariant MethodDeclarationImpl node) {
3200- var element = node.declaredElement! ;
3190+ var fragment = node.declaredFragment! ;
3191+ var element = fragment.element;
32013192 var returnType = element.returnType;
3202- var outerFunction = _enclosingFunction ;
3193+ var outerFunction = enclosingFunction ;
32033194 var outerAugmentation = enclosingAugmentation;
32043195
32053196 try {
3206- _enclosingFunction = element;
3207- if (element case AugmentableElement augmentation) {
3197+ enclosingFunction = element;
3198+ if (fragment case AugmentableElement augmentation) {
32083199 enclosingAugmentation = augmentation;
32093200 }
32103201 assert (_thisType == null );
@@ -3233,7 +3224,7 @@ class ResolverVisitor extends ThrowingAstVisitor<void>
32333224 flowAnalysis.bodyOrInitializer_exit ();
32343225 nullSafetyDeadCodeVerifier.flowEnd (node);
32353226 } finally {
3236- _enclosingFunction = outerFunction;
3227+ enclosingFunction = outerFunction;
32373228 enclosingAugmentation = outerAugmentation;
32383229 _thisType = null ;
32393230 }
0 commit comments