Skip to content

Commit 617e0e1

Browse files
scheglovCommit Queue
authored andcommitted
Elements. Migrate ResolverVisitor.
Use the return type of the method element, not a fragment, as a result report BODY_MIGHT_COMPLETE_NORMALLY in invalid fragments. Change-Id: I5a07fcc21695695cf9aeacaf6d35949c69b4c817 Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/411480 Reviewed-by: Paul Berry <[email protected]> Commit-Queue: Konstantin Shcheglov <[email protected]>
1 parent d070ea7 commit 617e0e1

File tree

6 files changed

+132
-128
lines changed

6 files changed

+132
-128
lines changed

pkg/analyzer/lib/src/dart/ast/ast.dart

Lines changed: 27 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -458,11 +458,16 @@ final class ArgumentListImpl extends AstNodeImpl implements ArgumentList {
458458
_correspondingStaticParameters = parameters;
459459
}
460460

461-
List<FormalParameterElement?>? get correspondingStaticParameters2 =>
461+
List<FormalParameterElementMixin?>? get correspondingStaticParameters2 =>
462462
_correspondingStaticParameters
463463
?.map((parameter) => parameter?.asElement2)
464464
.toList();
465465

466+
set correspondingStaticParameters2(
467+
List<FormalParameterElementMixin?>? value) {
468+
_correspondingStaticParameters = value?.map((e) => e?.asElement).toList();
469+
}
470+
466471
@override
467472
Token get endToken => rightParenthesis;
468473

@@ -3743,17 +3748,20 @@ base mixin CompoundAssignmentExpressionImpl
37433748
@experimental
37443749
@override
37453750
Element2? get readElement2 {
3746-
if (readElement is Fragment) {
3747-
return (readElement as Fragment).element;
3748-
} else if (readElement is Element2) {
3749-
return readElement as Element2;
3750-
}
3751-
return null;
3751+
return readElement?.asElement2;
3752+
}
3753+
3754+
set readElement2(Element2? value) {
3755+
readElement = value?.asElement;
37523756
}
37533757

37543758
@experimental
37553759
@override
37563760
Element2? get writeElement2 => writeElement.asElement2;
3761+
3762+
set writeElement2(Element2? value) {
3763+
writeElement = value?.asElement;
3764+
}
37573765
}
37583766

37593767
/// A conditional expression.
@@ -5179,7 +5187,7 @@ final class DefaultFormalParameterImpl extends FormalParameterImpl
51795187

51805188
@experimental
51815189
@override
5182-
FormalParameterFragment? get declaredFragment => _parameter.declaredFragment;
5190+
ParameterElementImpl? get declaredFragment => _parameter.declaredFragment;
51835191

51845192
@override
51855193
ExpressionImpl? get defaultValue => _defaultValue;
@@ -5699,9 +5707,13 @@ final class EnumConstantDeclarationImpl extends DeclarationImpl
56995707
ConstructorElement2? get constructorElement2 =>
57005708
constructorElement?.asElement2;
57015709

5710+
set constructorElement2(ConstructorElement2? value) {
5711+
constructorElement = value?.asElement;
5712+
}
5713+
57025714
@experimental
57035715
@override
5704-
FieldFragment? get declaredFragment => declaredElement as FieldFragment?;
5716+
FieldElementImpl? get declaredFragment => declaredElement;
57055717

57065718
@override
57075719
Token get endToken => arguments?.endToken ?? name;
@@ -6738,8 +6750,7 @@ final class ExtensionOverrideImpl extends ExpressionImpl
67386750
Token get beginToken => importPrefix?.name ?? name;
67396751

67406752
@override
6741-
ExtensionElementImpl get element =>
6742-
element2.firstFragment;
6753+
ExtensionElementImpl get element => element2.firstFragment;
67436754

67446755
@override
67456756
Token get endToken => _argumentList.endToken;
@@ -7685,8 +7696,7 @@ sealed class FormalParameterImpl extends AstNodeImpl
76857696

76867697
@experimental
76877698
@override
7688-
FormalParameterFragment? get declaredFragment =>
7689-
declaredElement as FormalParameterFragment?;
7699+
ParameterElementImpl? get declaredFragment => declaredElement;
76907700

76917701
@override
76927702
bool get isNamed => kind.isNamed;
@@ -10260,6 +10270,10 @@ final class IndexExpressionImpl extends ExpressionImpl
1026010270
@override
1026110271
MethodElement2? get element => staticElement?.asElement2;
1026210272

10273+
set element(MethodElement2? value) {
10274+
staticElement = value?.asElement;
10275+
}
10276+
1026310277
@override
1026410278
Token get endToken => rightBracket;
1026510279

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -284,7 +284,7 @@ abstract class FullInvocationInferrer<Node extends AstNodeImpl>
284284

285285
var parameters = _storeResult(typeArgumentTypes, invokeType);
286286
if (parameters != null) {
287-
argumentList.correspondingStaticParameters =
287+
argumentList.correspondingStaticParameters2 =
288288
ResolverVisitor.resolveArgumentsToParameters(
289289
argumentList: argumentList,
290290
formalParameters: parameters,

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

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -248,7 +248,7 @@ class ElementResolver {
248248
var parameters =
249249
_resolveArgumentsToFunction(argumentList, invokedConstructor);
250250
if (parameters != null) {
251-
argumentList.correspondingStaticParameters = parameters;
251+
argumentList.correspondingStaticParameters2 = parameters;
252252
}
253253
}
254254

@@ -323,7 +323,7 @@ class ElementResolver {
323323
var argumentList = node.argumentList;
324324
var parameters = _resolveArgumentsToFunction(argumentList, element);
325325
if (parameters != null) {
326-
argumentList.correspondingStaticParameters = parameters;
326+
argumentList.correspondingStaticParameters2 = parameters;
327327
}
328328
}
329329

@@ -397,7 +397,7 @@ class ElementResolver {
397397
enclosingConstructor: node.thisOrAncestorOfType<ConstructorDeclaration>(),
398398
);
399399
if (parameters != null) {
400-
argumentList.correspondingStaticParameters = parameters;
400+
argumentList.correspondingStaticParameters2 = parameters;
401401
}
402402
}
403403

@@ -440,7 +440,7 @@ class ElementResolver {
440440
/// the list of arguments. An error will be reported if any of the arguments
441441
/// cannot be matched to a parameter. Return the parameters that correspond to
442442
/// the arguments, or `null` if no correspondence could be computed.
443-
List<ParameterElementMixin?>? _resolveArgumentsToFunction(
443+
List<FormalParameterElementMixin?>? _resolveArgumentsToFunction(
444444
ArgumentList argumentList,
445445
ExecutableElement2? executableElement, {
446446
ConstructorDeclaration? enclosingConstructor,

0 commit comments

Comments
 (0)