Skip to content

Commit 69f0ebc

Browse files
author
Dart CI
committed
Version 2.14.0-373.0.dev
Merge commit '1d55cd7c2f9d3f3f53462c921d40ca5f1abe7729' into 'dev'
2 parents a171b36 + 1d55cd7 commit 69f0ebc

File tree

2 files changed

+33
-58
lines changed

2 files changed

+33
-58
lines changed

pkg/analyzer/lib/src/generated/resolver.dart

Lines changed: 32 additions & 57 deletions
Original file line numberDiff line numberDiff line change
@@ -210,10 +210,6 @@ class ResolverVisitor extends ScopedVisitor with ErrorDetectionHelpers {
210210
@override
211211
final TypeSystemImpl typeSystem;
212212

213-
/// The element representing the function containing the current node, or
214-
/// `null` if the current node is not contained in a function.
215-
ExecutableElement? _enclosingFunction;
216-
217213
/// The helper for tracking if the current location has access to `this`.
218214
final ThisAccessTracker _thisAccessTracker = ThisAccessTracker.unit();
219215

@@ -1223,13 +1219,10 @@ class ResolverVisitor extends ScopedVisitor with ErrorDetectionHelpers {
12231219

12241220
@override
12251221
void visitConstructorDeclaration(ConstructorDeclaration node) {
1226-
var outerFunction = _enclosingFunction;
1227-
_enclosingFunction = node.declaredElement;
1228-
12291222
flowAnalysis!.topLevelDeclaration_enter(node, node.parameters);
12301223
flowAnalysis!.executableDeclaration_enter(node, node.parameters, false);
12311224

1232-
var returnType = _enclosingFunction!.type.returnType;
1225+
var returnType = node.declaredElement!.type.returnType;
12331226
InferenceContext.setType(node.body, returnType);
12341227

12351228
super.visitConstructorDeclaration(node);
@@ -1245,8 +1238,6 @@ class ResolverVisitor extends ScopedVisitor with ErrorDetectionHelpers {
12451238
flowAnalysis!.executableDeclaration_exit(node.body, false);
12461239
flowAnalysis!.topLevelDeclaration_exit();
12471240
nullSafetyDeadCodeVerifier.flowEnd(node);
1248-
1249-
_enclosingFunction = outerFunction;
12501241
}
12511242

12521243
@override
@@ -1447,9 +1438,6 @@ class ResolverVisitor extends ScopedVisitor with ErrorDetectionHelpers {
14471438

14481439
@override
14491440
void visitFunctionDeclaration(FunctionDeclaration node) {
1450-
var outerFunction = _enclosingFunction;
1451-
_enclosingFunction = node.declaredElement;
1452-
14531441
bool isLocal = node.parent is FunctionDeclarationStatement;
14541442

14551443
if (isLocal) {
@@ -1464,7 +1452,7 @@ class ResolverVisitor extends ScopedVisitor with ErrorDetectionHelpers {
14641452
isLocal,
14651453
);
14661454

1467-
var functionType = _enclosingFunction!.type;
1455+
var functionType = node.declaredElement!.type;
14681456
InferenceContext.setType(node.functionExpression, functionType);
14691457

14701458
super.visitFunctionDeclaration(node);
@@ -1489,7 +1477,6 @@ class ResolverVisitor extends ScopedVisitor with ErrorDetectionHelpers {
14891477
}
14901478
nullSafetyDeadCodeVerifier.flowEnd(node);
14911479

1492-
_enclosingFunction = outerFunction;
14931480
node.accept(elementResolver);
14941481
// Note: no need to call the typeAnalyzer since it does not override
14951482
// visitFunctionDeclaration
@@ -1503,6 +1490,8 @@ class ResolverVisitor extends ScopedVisitor with ErrorDetectionHelpers {
15031490

15041491
@override
15051492
void visitFunctionExpression(covariant FunctionExpressionImpl node) {
1493+
// Note: we have to update _enclosingFunction because we don't make use of
1494+
// super.visitFunctionExpression.
15061495
var outerFunction = _enclosingFunction;
15071496
_enclosingFunction = node.declaredElement;
15081497

@@ -1712,13 +1701,10 @@ class ResolverVisitor extends ScopedVisitor with ErrorDetectionHelpers {
17121701

17131702
@override
17141703
void visitMethodDeclaration(MethodDeclaration node) {
1715-
var outerFunction = _enclosingFunction;
1716-
_enclosingFunction = node.declaredElement;
1717-
17181704
flowAnalysis!.topLevelDeclaration_enter(node, node.parameters);
17191705
flowAnalysis!.executableDeclaration_enter(node, node.parameters, false);
17201706

1721-
DartType returnType = _enclosingFunction!.returnType;
1707+
DartType returnType = node.declaredElement!.returnType;
17221708
InferenceContext.setType(node.body, returnType);
17231709

17241710
super.visitMethodDeclaration(node);
@@ -1734,7 +1720,6 @@ class ResolverVisitor extends ScopedVisitor with ErrorDetectionHelpers {
17341720
flowAnalysis!.topLevelDeclaration_exit();
17351721
nullSafetyDeadCodeVerifier.flowEnd(node);
17361722

1737-
_enclosingFunction = outerFunction;
17381723
node.accept(elementResolver);
17391724
// Note: no need to call the typeAnalyzer since it does not override
17401725
// visitMethodDeclaration.
@@ -2418,6 +2403,10 @@ abstract class ScopedVisitor extends UnifyingAstVisitor<void> {
24182403
/// visited, or `null` if we are not in the scope of an extension.
24192404
ExtensionElement? enclosingExtension;
24202405

2406+
/// The element representing the function containing the current node, or
2407+
/// `null` if the current node is not contained in a function.
2408+
ExecutableElement? _enclosingFunction;
2409+
24212410
/// Initialize a newly created visitor to resolve the nodes in a compilation
24222411
/// unit.
24232412
///
@@ -2575,6 +2564,8 @@ abstract class ScopedVisitor extends UnifyingAstVisitor<void> {
25752564

25762565
@override
25772566
void visitConstructorDeclaration(ConstructorDeclaration node) {
2567+
var outerFunction = _enclosingFunction;
2568+
_enclosingFunction = node.declaredElement;
25782569
Scope outerScope = nameScope;
25792570
try {
25802571
ConstructorElement element = node.declaredElement!;
@@ -2604,6 +2595,7 @@ abstract class ScopedVisitor extends UnifyingAstVisitor<void> {
26042595
visitConstructorDeclarationInScope(node);
26052596
} finally {
26062597
nameScope = outerScope;
2598+
_enclosingFunction = outerFunction;
26072599
}
26082600
}
26092601

@@ -2782,6 +2774,9 @@ abstract class ScopedVisitor extends UnifyingAstVisitor<void> {
27822774

27832775
@override
27842776
void visitFunctionDeclaration(FunctionDeclaration node) {
2777+
var outerFunction = _enclosingFunction;
2778+
_enclosingFunction = node.declaredElement;
2779+
27852780
node.metadata.accept(this);
27862781
Scope outerScope = nameScope;
27872782
try {
@@ -2793,6 +2788,7 @@ abstract class ScopedVisitor extends UnifyingAstVisitor<void> {
27932788
visitFunctionDeclarationInScope(node);
27942789
} finally {
27952790
nameScope = outerScope;
2791+
_enclosingFunction = outerFunction;
27962792
}
27972793
}
27982794

@@ -2813,6 +2809,8 @@ abstract class ScopedVisitor extends UnifyingAstVisitor<void> {
28132809
return;
28142810
}
28152811

2812+
var outerFunction = _enclosingFunction;
2813+
_enclosingFunction = node.declaredElement;
28162814
Scope outerScope = nameScope;
28172815
try {
28182816
ExecutableElement element = node.declaredElement!;
@@ -2823,6 +2821,7 @@ abstract class ScopedVisitor extends UnifyingAstVisitor<void> {
28232821
super.visitFunctionExpression(node);
28242822
} finally {
28252823
nameScope = outerScope;
2824+
_enclosingFunction = outerFunction;
28262825
}
28272826
}
28282827

@@ -2949,6 +2948,9 @@ abstract class ScopedVisitor extends UnifyingAstVisitor<void> {
29492948

29502949
@override
29512950
void visitMethodDeclaration(MethodDeclaration node) {
2951+
var outerFunction = _enclosingFunction;
2952+
_enclosingFunction = node.declaredElement;
2953+
29522954
node.metadata.accept(this);
29532955
Scope outerScope = nameScope;
29542956
try {
@@ -2960,6 +2962,7 @@ abstract class ScopedVisitor extends UnifyingAstVisitor<void> {
29602962
visitMethodDeclarationInScope(node);
29612963
} finally {
29622964
nameScope = outerScope;
2965+
_enclosingFunction = outerFunction;
29632966
}
29642967
}
29652968

@@ -3145,10 +3148,6 @@ abstract class ScopedVisitor extends UnifyingAstVisitor<void> {
31453148
/// Instances of the class `VariableResolverVisitor` are used to resolve
31463149
/// [SimpleIdentifier]s to local variables and formal parameters.
31473150
class VariableResolverVisitor extends ScopedVisitor {
3148-
/// The method or function that we are currently visiting, or `null` if we are
3149-
/// not inside a method or function.
3150-
ExecutableElement? _enclosingFunction;
3151-
31523151
/// The container with information about local variables.
31533152
final LocalVariableInfo _localVariableInfo = LocalVariableInfo();
31543153

@@ -3174,43 +3173,25 @@ class VariableResolverVisitor extends ScopedVisitor {
31743173

31753174
@override
31763175
void visitConstructorDeclaration(ConstructorDeclaration node) {
3177-
var outerFunction = _enclosingFunction;
3178-
try {
3179-
(node.body as FunctionBodyImpl).localVariableInfo = _localVariableInfo;
3180-
_enclosingFunction = node.declaredElement;
3181-
super.visitConstructorDeclaration(node);
3182-
} finally {
3183-
_enclosingFunction = outerFunction;
3184-
}
3176+
(node.body as FunctionBodyImpl).localVariableInfo = _localVariableInfo;
3177+
super.visitConstructorDeclaration(node);
31853178
}
31863179

31873180
@override
31883181
void visitExportDirective(ExportDirective node) {}
31893182

31903183
@override
31913184
void visitFunctionDeclaration(FunctionDeclaration node) {
3192-
var outerFunction = _enclosingFunction;
3193-
try {
3194-
(node.functionExpression.body as FunctionBodyImpl).localVariableInfo =
3195-
_localVariableInfo;
3196-
_enclosingFunction = node.declaredElement;
3197-
super.visitFunctionDeclaration(node);
3198-
} finally {
3199-
_enclosingFunction = outerFunction;
3200-
}
3185+
(node.functionExpression.body as FunctionBodyImpl).localVariableInfo =
3186+
_localVariableInfo;
3187+
super.visitFunctionDeclaration(node);
32013188
}
32023189

32033190
@override
32043191
void visitFunctionExpression(FunctionExpression node) {
32053192
if (node.parent is! FunctionDeclaration) {
3206-
var outerFunction = _enclosingFunction;
3207-
try {
3208-
(node.body as FunctionBodyImpl).localVariableInfo = _localVariableInfo;
3209-
_enclosingFunction = node.declaredElement;
3210-
super.visitFunctionExpression(node);
3211-
} finally {
3212-
_enclosingFunction = outerFunction;
3213-
}
3193+
(node.body as FunctionBodyImpl).localVariableInfo = _localVariableInfo;
3194+
super.visitFunctionExpression(node);
32143195
} else {
32153196
super.visitFunctionExpression(node);
32163197
}
@@ -3221,14 +3202,8 @@ class VariableResolverVisitor extends ScopedVisitor {
32213202

32223203
@override
32233204
void visitMethodDeclaration(MethodDeclaration node) {
3224-
var outerFunction = _enclosingFunction;
3225-
try {
3226-
(node.body as FunctionBodyImpl).localVariableInfo = _localVariableInfo;
3227-
_enclosingFunction = node.declaredElement;
3228-
super.visitMethodDeclaration(node);
3229-
} finally {
3230-
_enclosingFunction = outerFunction;
3231-
}
3205+
(node.body as FunctionBodyImpl).localVariableInfo = _localVariableInfo;
3206+
super.visitMethodDeclaration(node);
32323207
}
32333208

32343209
@override

tools/VERSION

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,5 +27,5 @@ CHANNEL dev
2727
MAJOR 2
2828
MINOR 14
2929
PATCH 0
30-
PRERELEASE 372
30+
PRERELEASE 373
3131
PRERELEASE_PATCH 0

0 commit comments

Comments
 (0)