Skip to content

Commit 749ee4e

Browse files
author
Dart CI
committed
Version 2.14.0-388.0.dev
Merge commit '3bec5e5ecd13e5696e8e503750fef65a60692824' into 'dev'
2 parents cf20a69 + 3bec5e5 commit 749ee4e

10 files changed

Lines changed: 214 additions & 263 deletions

File tree

DEPS

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -73,7 +73,7 @@ vars = {
7373

7474
# Revisions of /third_party/* dependencies.
7575
"args_rev": "bf4c8796881b62fd5d3f6d86ab43014f9651eb20",
76-
"async_rev": "25a7e2ec39c03622b86918cb9ce3e7d00dd283d1",
76+
"async_rev": "88cc6079037da08dcb31cf8dcd62173c2ddf1e89",
7777
"bazel_worker_rev": "0885637b037979afbf5bcd05fd748b309fd669c0",
7878
"benchmark_harness_rev": "c546dbd9f639f75cd2f75de8df2eb9f8ea15e8e7",
7979
"boolean_selector_rev": "665e6921ab246569420376f827bff4585dff0b14",

pkg/analysis_server/lib/src/services/correction/fix.dart

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -127,7 +127,7 @@ class DartFixKind {
127127
static const ADD_NE_NULL_MULTI = FixKind('dart.fix.add.neNull.multi',
128128
DartFixKindPriority.IN_FILE, 'Add != null everywhere in file');
129129
static const ADD_NULL_CHECK = FixKind('dart.fix.add.nullCheck',
130-
DartFixKindPriority.DEFAULT, 'Add a null check (!)');
130+
DartFixKindPriority.DEFAULT - 1, 'Add a null check (!)',);
131131
static const ADD_OVERRIDE = FixKind('dart.fix.add.override',
132132
DartFixKindPriority.DEFAULT, "Add '@override' annotation");
133133
static const ADD_OVERRIDE_MULTI = FixKind(

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

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,10 @@ class FunctionExpressionResolver {
3232
TypeSystemImpl get _typeSystem => _resolver.typeSystem;
3333

3434
void resolve(FunctionExpressionImpl node) {
35-
var isFunctionDeclaration = node.parent is FunctionDeclaration;
35+
var parent = node.parent;
36+
// Note: `isFunctionDeclaration` must have an explicit type to work around
37+
// https://github.com/dart-lang/language/issues/1785.
38+
bool isFunctionDeclaration = parent is FunctionDeclaration;
3639
var body = node.body;
3740

3841
if (_resolver.flowAnalysis!.flow != null && !isFunctionDeclaration) {
@@ -53,6 +56,11 @@ class FunctionExpressionResolver {
5356
}
5457

5558
node.visitChildren(_resolver);
59+
if (isFunctionDeclaration) {
60+
// A side effect of visiting the children is that the parameters are now
61+
// in scope, so we can visit the documentation comment now.
62+
parent.documentationComment?.accept(_resolver);
63+
}
5664
_resolve2(node);
5765

5866
if (_resolver.flowAnalysis!.flow != null && !isFunctionDeclaration) {

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

Lines changed: 14 additions & 82 deletions
Original file line numberDiff line numberDiff line change
@@ -739,13 +739,6 @@ class ResolverVisitor extends ScopedVisitor with ErrorDetectionHelpers {
739739
}
740740
}
741741

742-
/// Visit the given [comment] if it is not `null`.
743-
void safelyVisitComment(Comment? comment) {
744-
if (comment != null) {
745-
super.visitComment(comment);
746-
}
747-
}
748-
749742
void setReadElement(Expression node, Element? element) {
750743
DartType readType = DynamicTypeImpl.instance;
751744
if (node is IndexExpression) {
@@ -1096,52 +1089,6 @@ class ResolverVisitor extends ScopedVisitor with ErrorDetectionHelpers {
10961089
// visitClassTypeAlias.
10971090
}
10981091

1099-
@override
1100-
void visitComment(Comment node) {
1101-
var parent = node.parent;
1102-
if (parent is FunctionDeclaration ||
1103-
parent is FunctionTypeAlias ||
1104-
parent is ConstructorDeclaration) {
1105-
return;
1106-
}
1107-
1108-
// TODO(scheglov) Change corresponding visiting places to visit comments
1109-
// with name scopes set for correct comments resolution.
1110-
if (parent is GenericTypeAlias) {
1111-
var element = parent.declaredElement as TypeAliasElement;
1112-
var outerScope = nameScope;
1113-
try {
1114-
nameScope = TypeParameterScope(nameScope, element.typeParameters);
1115-
1116-
var aliasedElement = element.aliasedElement;
1117-
if (aliasedElement is GenericFunctionTypeElement) {
1118-
nameScope = FormalParameterScope(
1119-
TypeParameterScope(nameScope, aliasedElement.typeParameters),
1120-
aliasedElement.parameters,
1121-
);
1122-
}
1123-
1124-
super.visitComment(node);
1125-
return;
1126-
} finally {
1127-
nameScope = outerScope;
1128-
}
1129-
} else if (parent is MethodDeclaration) {
1130-
var outerScope = nameScope;
1131-
try {
1132-
var element = parent.declaredElement!;
1133-
nameScope = FormalParameterScope(nameScope, element.parameters);
1134-
1135-
super.visitComment(node);
1136-
return;
1137-
} finally {
1138-
nameScope = outerScope;
1139-
}
1140-
}
1141-
1142-
super.visitComment(node);
1143-
}
1144-
11451092
@override
11461093
void visitCommentReference(CommentReference node) {
11471094
//
@@ -1246,7 +1193,6 @@ class ResolverVisitor extends ScopedVisitor with ErrorDetectionHelpers {
12461193
// element resolver and type analyzer to visit the constructor declaration.
12471194
node.accept(elementResolver);
12481195
node.accept(typeAnalyzer);
1249-
safelyVisitComment(node.documentationComment);
12501196
}
12511197

12521198
@override
@@ -1479,12 +1425,6 @@ class ResolverVisitor extends ScopedVisitor with ErrorDetectionHelpers {
14791425
// visitFunctionDeclaration
14801426
}
14811427

1482-
@override
1483-
void visitFunctionDeclarationInScope(FunctionDeclaration node) {
1484-
super.visitFunctionDeclarationInScope(node);
1485-
safelyVisitComment(node.documentationComment);
1486-
}
1487-
14881428
@override
14891429
void visitFunctionExpression(covariant FunctionExpressionImpl node) {
14901430
// Note: we have to update _enclosingFunction because we don't make use of
@@ -1535,12 +1475,6 @@ class ResolverVisitor extends ScopedVisitor with ErrorDetectionHelpers {
15351475
// visitFunctionTypeAlias.
15361476
}
15371477

1538-
@override
1539-
void visitFunctionTypeAliasInScope(FunctionTypeAlias node) {
1540-
super.visitFunctionTypeAliasInScope(node);
1541-
safelyVisitComment(node.documentationComment);
1542-
}
1543-
15441478
@override
15451479
void visitFunctionTypedFormalParameter(FunctionTypedFormalParameter node) {
15461480
super.visitFunctionTypedFormalParameter(node);
@@ -1557,12 +1491,6 @@ class ResolverVisitor extends ScopedVisitor with ErrorDetectionHelpers {
15571491
// visitGenericTypeAlias.
15581492
}
15591493

1560-
@override
1561-
void visitGenericTypeAliasInFunctionScope(GenericTypeAlias node) {
1562-
super.visitGenericTypeAliasInFunctionScope(node);
1563-
safelyVisitComment(node.documentationComment);
1564-
}
1565-
15661494
@override
15671495
void visitHideCombinator(HideCombinator node) {}
15681496

@@ -2574,7 +2502,6 @@ abstract class ScopedVisitor extends UnifyingAstVisitor<void> {
25742502
try {
25752503
ConstructorElement element = node.declaredElement!;
25762504

2577-
node.documentationComment?.accept(this);
25782505
node.metadata.accept(this);
25792506
node.returnType.accept(this);
25802507
node.name?.accept(this);
@@ -2604,6 +2531,7 @@ abstract class ScopedVisitor extends UnifyingAstVisitor<void> {
26042531
}
26052532

26062533
void visitConstructorDeclarationInScope(ConstructorDeclaration node) {
2534+
node.documentationComment?.accept(this);
26072535
node.body.accept(this);
26082536
}
26092537

@@ -2801,17 +2729,18 @@ abstract class ScopedVisitor extends UnifyingAstVisitor<void> {
28012729
void visitFunctionDeclarationInScope(FunctionDeclaration node) {
28022730
// Note: we don't visit metadata because it's not inside the function's type
28032731
// parameter scope. It was already visited in [visitFunctionDeclaration].
2804-
node.documentationComment?.accept(this);
28052732
node.returnType?.accept(this);
28062733
node.name.accept(this);
28072734
node.functionExpression.accept(this);
28082735
}
28092736

28102737
@override
28112738
void visitFunctionExpression(FunctionExpression node) {
2812-
if (node.parent is FunctionDeclaration) {
2739+
var parent = node.parent;
2740+
if (parent is FunctionDeclaration) {
28132741
// We have already created a function scope and don't need to do so again.
28142742
super.visitFunctionExpression(node);
2743+
parent.documentationComment?.accept(this);
28152744
return;
28162745
}
28172746

@@ -2848,11 +2777,13 @@ abstract class ScopedVisitor extends UnifyingAstVisitor<void> {
28482777
// Note: we don't visit metadata because it's not inside the function type
28492778
// alias's type parameter scope. It was already visited in
28502779
// [visitFunctionTypeAlias].
2851-
node.documentationComment?.accept(this);
28522780
node.returnType?.accept(this);
28532781
node.name.accept(this);
28542782
node.typeParameters?.accept(this);
28552783
node.parameters.accept(this);
2784+
// Visiting the parameters added them to the scope as a side effect. So it
2785+
// is safe to visit the documentation comment now.
2786+
node.documentationComment?.accept(this);
28562787
}
28572788

28582789
@override
@@ -2917,21 +2848,20 @@ abstract class ScopedVisitor extends UnifyingAstVisitor<void> {
29172848

29182849
var aliasedElement = element.aliasedElement;
29192850
if (aliasedElement is GenericFunctionTypeElement) {
2920-
nameScope = FormalParameterScope(nameScope, aliasedElement.parameters);
2921-
visitGenericTypeAliasInFunctionScope(node);
2851+
nameScope = FormalParameterScope(
2852+
TypeParameterScope(nameScope, aliasedElement.typeParameters),
2853+
aliasedElement.parameters);
29222854
}
2855+
node.documentationComment?.accept(this);
29232856
} finally {
29242857
nameScope = outerScope;
29252858
}
29262859
}
29272860

2928-
void visitGenericTypeAliasInFunctionScope(GenericTypeAlias node) {}
2929-
29302861
void visitGenericTypeAliasInScope(GenericTypeAlias node) {
29312862
// Note: we don't visit metadata because it's not inside the generic type
29322863
// alias's type parameter scope. It was already visited in
29332864
// [visitGenericTypeAlias].
2934-
node.documentationComment?.accept(this);
29352865
node.name.accept(this);
29362866
node.typeParameters?.accept(this);
29372867
node.type.accept(this);
@@ -2978,11 +2908,13 @@ abstract class ScopedVisitor extends UnifyingAstVisitor<void> {
29782908
void visitMethodDeclarationInScope(MethodDeclaration node) {
29792909
// Note: we don't visit metadata because it's not inside the method's type
29802910
// parameter scope. It was already visited in [visitMethodDeclaration].
2981-
node.documentationComment?.accept(this);
29822911
node.returnType?.accept(this);
29832912
node.name.accept(this);
29842913
node.typeParameters?.accept(this);
29852914
node.parameters?.accept(this);
2915+
// Visiting the parameters added them to the scope as a side effect. So it
2916+
// is safe to visit the documentation comment now.
2917+
node.documentationComment?.accept(this);
29862918
node.body.accept(this);
29872919
}
29882920

0 commit comments

Comments
 (0)