Skip to content

Commit 55154ec

Browse files
scheglovCommit Queue
authored andcommitted
Elements. Remove 'augmentedIfReally'.
Change-Id: Id6ebeaea49627de09207c96652c600116b71c5bf Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/392500 Reviewed-by: Phil Quitslund <[email protected]> Reviewed-by: Brian Wilkerson <[email protected]> Commit-Queue: Konstantin Shcheglov <[email protected]>
1 parent 998cd10 commit 55154ec

File tree

2 files changed

+66
-102
lines changed

2 files changed

+66
-102
lines changed

pkg/analyzer/lib/src/dart/element/element.dart

Lines changed: 0 additions & 45 deletions
Original file line numberDiff line numberDiff line change
@@ -307,15 +307,6 @@ class ClassElementImpl extends ClassOrMixinElementImpl
307307
return element;
308308
}
309309

310-
AugmentedClassElementImpl? get augmentedIfReally {
311-
if (augmentationTarget != null) {
312-
if (augmented case AugmentedClassElementImpl augmented) {
313-
return augmented;
314-
}
315-
}
316-
return null;
317-
}
318-
319310
@override
320311
List<Element2> get children2 {
321312
throw StateError('This is a fragment');
@@ -3397,15 +3388,6 @@ class EnumElementImpl extends InterfaceElementImpl
33973388
return element;
33983389
}
33993390

3400-
AugmentedEnumElementImpl? get augmentedIfReally {
3401-
if (augmentationTarget != null) {
3402-
if (augmented case AugmentedEnumElementImpl augmented) {
3403-
return augmented;
3404-
}
3405-
}
3406-
return null;
3407-
}
3408-
34093391
@override
34103392
List<Element2> get children2 {
34113393
throw StateError('This is a fragment');
@@ -3665,15 +3647,6 @@ class ExtensionElementImpl extends InstanceElementImpl
36653647
return element;
36663648
}
36673649

3668-
AugmentedExtensionElementImpl? get augmentedIfReally {
3669-
if (augmentationTarget != null) {
3670-
if (augmented case AugmentedExtensionElementImpl augmented) {
3671-
return augmented;
3672-
}
3673-
}
3674-
return null;
3675-
}
3676-
36773650
@override
36783651
List<Element> get children => [
36793652
...super.children,
@@ -3794,15 +3767,6 @@ class ExtensionTypeElementImpl extends InterfaceElementImpl
37943767
return element;
37953768
}
37963769

3797-
AugmentedExtensionTypeElementImpl? get augmentedIfReally {
3798-
if (augmentationTarget != null) {
3799-
if (augmented case AugmentedExtensionTypeElementImpl augmented) {
3800-
return augmented;
3801-
}
3802-
}
3803-
return null;
3804-
}
3805-
38063770
@override
38073771
List<Element2> get children2 {
38083772
throw StateError('This is a fragment');
@@ -7736,15 +7700,6 @@ class MixinElementImpl extends ClassOrMixinElementImpl
77367700
return element;
77377701
}
77387702

7739-
AugmentedMixinElementImpl? get augmentedIfReally {
7740-
if (augmentationTarget != null) {
7741-
if (augmented case AugmentedMixinElementImpl augmented) {
7742-
return augmented;
7743-
}
7744-
}
7745-
return null;
7746-
}
7747-
77487703
@override
77497704
List<Element2> get children2 {
77507705
throw StateError('This is a fragment');

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

Lines changed: 66 additions & 57 deletions
Original file line numberDiff line numberDiff line change
@@ -450,35 +450,37 @@ class ErrorVerifier extends RecursiveAstVisitor<void>
450450
@override
451451
void visitClassDeclaration(covariant ClassDeclarationImpl node) {
452452
try {
453-
var element = node.declaredElement!;
453+
var declaredFragment = node.declaredElement!;
454+
var declaredElement = declaredFragment.element;
455+
var firstFragment = declaredElement.firstFragment;
454456

455457
_checkAugmentations(
456458
augmentKeyword: node.augmentKeyword,
457-
element: element,
459+
element: declaredFragment,
458460
);
459461

460462
_checkClassAugmentationModifiers(
461463
augmentKeyword: node.augmentKeyword,
462464
augmentationNode: node,
463-
augmentationElement: element,
465+
augmentationElement: declaredFragment,
464466
);
465467

466-
if (element.augmentedIfReally case var augmented?) {
468+
if (!identical(firstFragment, declaredFragment)) {
467469
_checkAugmentationTypeParameters(
468470
nameToken: node.name,
469471
typeParameterList: node.typeParameters,
470-
declarationTypeParameters: augmented.firstFragment.typeParameters,
472+
declarationTypeParameters: firstFragment.typeParameters,
471473
);
472474
}
473475

474476
_checkClassAugmentationTargetAlreadyHasExtendsClause(
475477
node: node,
476-
augmentationTarget: element.augmentationTarget,
478+
augmentationTarget: declaredFragment.augmentationTarget,
477479
);
478480

479481
_isInNativeClass = node.nativeClause != null;
480482

481-
var augmented = element.augmented;
483+
var augmented = declaredFragment.augmented;
482484
var declarationElement = augmented.firstFragment;
483485
_enclosingClass = declarationElement;
484486

@@ -499,7 +501,8 @@ class ErrorVerifier extends RecursiveAstVisitor<void>
499501
var moreChecks = _checkClassInheritance(
500502
declarationElement, node, superclass, withClause, implementsClause);
501503
if (moreChecks) {
502-
_checkForNoDefaultSuperConstructorImplicit(element, augmented);
504+
_checkForNoDefaultSuperConstructorImplicit(
505+
declaredFragment, augmented);
503506
}
504507
}
505508

@@ -508,8 +511,8 @@ class ErrorVerifier extends RecursiveAstVisitor<void>
508511
.addConstructors(errorReporter, augmented, members);
509512
}
510513

511-
_checkForConflictingClassMembers(element);
512-
_checkForFinalNotInitializedInClass(element, members);
514+
_checkForConflictingClassMembers(declaredFragment);
515+
_checkForFinalNotInitializedInClass(declaredFragment, members);
513516
_checkForBadFunctionUse(
514517
superclass: node.extendsClause?.superclass,
515518
withClause: node.withClause,
@@ -518,7 +521,7 @@ class ErrorVerifier extends RecursiveAstVisitor<void>
518521
_checkForWrongTypeParameterVarianceInSuperinterfaces();
519522
_checkForMainFunction1(node.name, node.declaredElement!);
520523
_checkForMixinClassErrorCodes(node, members, superclass, withClause);
521-
_reportMacroDiagnostics(element);
524+
_reportMacroDiagnostics(declaredFragment);
522525

523526
GetterSetterTypesVerifier(
524527
typeSystem: typeSystem,
@@ -668,30 +671,32 @@ class ErrorVerifier extends RecursiveAstVisitor<void>
668671
}
669672

670673
@override
671-
void visitEnumDeclaration(EnumDeclaration node) {
674+
void visitEnumDeclaration(covariant EnumDeclarationImpl node) {
672675
try {
673-
var element = node.declaredElement as EnumElementImpl;
676+
var declaredFragment = node.declaredElement!;
677+
var declaredElement = declaredFragment.element;
678+
var firstFragment = declaredElement.firstFragment;
674679

675680
_checkAugmentations(
676681
augmentKeyword: node.augmentKeyword,
677-
element: element,
682+
element: declaredFragment,
678683
);
679684

680-
if (element.augmentedIfReally case var augmented?) {
685+
if (!identical(firstFragment, declaredFragment)) {
681686
_checkAugmentationTypeParameters(
682687
nameToken: node.name,
683688
typeParameterList: node.typeParameters,
684-
declarationTypeParameters: augmented.firstFragment.typeParameters,
689+
declarationTypeParameters: firstFragment.typeParameters,
685690
);
686691
}
687692

688-
var augmented = element.augmented;
693+
var augmented = declaredFragment.augmented;
689694
var declarationElement = augmented.firstFragment;
690695
_enclosingClass = declarationElement;
691696

692697
_checkForBuiltInIdentifierAsName(
693698
node.name, CompileTimeErrorCode.BUILT_IN_IDENTIFIER_AS_TYPE_NAME);
694-
_checkForConflictingEnumTypeVariableErrorCodes(element);
699+
_checkForConflictingEnumTypeVariableErrorCodes(declaredFragment);
695700
var implementsClause = node.implementsClause;
696701
var withClause = node.withClause;
697702

@@ -700,8 +705,8 @@ class ErrorVerifier extends RecursiveAstVisitor<void>
700705
declarationElement, node, null, withClause, implementsClause);
701706
}
702707

703-
if (!element.isAugmentation) {
704-
if (element.augmented.constants.isEmpty) {
708+
if (!declaredFragment.isAugmentation) {
709+
if (declaredFragment.augmented.constants.isEmpty) {
705710
errorReporter.atToken(
706711
node.name,
707712
CompileTimeErrorCode.ENUM_WITHOUT_CONSTANTS,
@@ -712,15 +717,15 @@ class ErrorVerifier extends RecursiveAstVisitor<void>
712717
var members = node.members;
713718
libraryContext.constructorFieldsVerifier
714719
.addConstructors(errorReporter, augmented, members);
715-
_checkForFinalNotInitializedInClass(element, members);
720+
_checkForFinalNotInitializedInClass(declaredFragment, members);
716721
_checkForWrongTypeParameterVarianceInSuperinterfaces();
717722
_checkForMainFunction1(node.name, node.declaredElement!);
718-
_checkForEnumInstantiatedToBoundsIsNotWellBounded(node, element);
723+
_checkForEnumInstantiatedToBoundsIsNotWellBounded(node, declaredFragment);
719724

720725
GetterSetterTypesVerifier(
721726
typeSystem: typeSystem,
722727
errorReporter: errorReporter,
723-
).checkStaticAccessors(element.accessors);
728+
).checkStaticAccessors(declaredFragment.accessors);
724729

725730
super.visitEnumDeclaration(node);
726731
} finally {
@@ -753,31 +758,33 @@ class ErrorVerifier extends RecursiveAstVisitor<void>
753758

754759
@override
755760
void visitExtensionDeclaration(covariant ExtensionDeclarationImpl node) {
756-
var element = node.declaredElement!;
761+
var declaredFragment = node.declaredElement!;
762+
var declaredElement = declaredFragment.element;
763+
var firstFragment = declaredElement.firstFragment;
757764

758765
_checkAugmentations(
759766
augmentKeyword: node.augmentKeyword,
760-
element: element,
767+
element: declaredFragment,
761768
);
762769

763-
if (element.augmentedIfReally case var augmented?) {
770+
if (!identical(firstFragment, declaredFragment)) {
764771
if (node.name case var nameToken?) {
765772
_checkAugmentationTypeParameters(
766773
nameToken: nameToken,
767774
typeParameterList: node.typeParameters,
768-
declarationTypeParameters: augmented.firstFragment.typeParameters,
775+
declarationTypeParameters: firstFragment.typeParameters,
769776
);
770777
}
771778
}
772779

773-
_enclosingExtension = element;
780+
_enclosingExtension = declaredFragment;
774781
_checkForConflictingExtensionTypeVariableErrorCodes();
775-
_checkForFinalNotInitializedInClass(element, node.members);
782+
_checkForFinalNotInitializedInClass(declaredFragment, node.members);
776783

777784
GetterSetterTypesVerifier(
778785
typeSystem: typeSystem,
779786
errorReporter: errorReporter,
780-
).checkExtension(element);
787+
).checkExtension(declaredFragment);
781788

782789
var name = node.name;
783790
if (name != null) {
@@ -793,57 +800,57 @@ class ErrorVerifier extends RecursiveAstVisitor<void>
793800
covariant ExtensionTypeDeclarationImpl node,
794801
) {
795802
try {
796-
var element = node.declaredElement!;
797-
var augmented = element.augmented;
798-
var declarationElement = augmented.firstFragment;
803+
var declaredFragment = node.declaredElement!;
804+
var declaredElement = declaredFragment.augmented;
805+
var firstFragment = declaredElement.firstFragment;
799806

800807
_checkAugmentations(
801808
augmentKeyword: node.augmentKeyword,
802-
element: element,
809+
element: declaredFragment,
803810
);
804811

805-
if (element.augmentedIfReally case var augmented?) {
812+
if (!identical(firstFragment, declaredFragment)) {
806813
_checkAugmentationTypeParameters(
807814
nameToken: node.name,
808815
typeParameterList: node.typeParameters,
809-
declarationTypeParameters: augmented.firstFragment.typeParameters,
816+
declarationTypeParameters: firstFragment.typeParameters,
810817
);
811818
}
812819

813-
_enclosingClass = declarationElement;
820+
_enclosingClass = firstFragment;
814821

815822
_checkForBuiltInIdentifierAsName(node.name,
816823
CompileTimeErrorCode.BUILT_IN_IDENTIFIER_AS_EXTENSION_TYPE_NAME);
817-
_checkForConflictingExtensionTypeTypeVariableErrorCodes(element);
824+
_checkForConflictingExtensionTypeTypeVariableErrorCodes(declaredFragment);
818825

819826
var members = node.members;
820827
_checkForRepeatedType(
821-
libraryContext.setOfImplements(declarationElement),
828+
libraryContext.setOfImplements(firstFragment),
822829
node.implementsClause?.interfaces,
823830
CompileTimeErrorCode.IMPLEMENTS_REPEATED,
824831
);
825-
_checkForConflictingClassMembers(element);
832+
_checkForConflictingClassMembers(declaredFragment);
826833
_checkForConflictingGenerics(node);
827834
libraryContext.constructorFieldsVerifier
828-
.addConstructors(errorReporter, augmented, members);
835+
.addConstructors(errorReporter, declaredElement, members);
829836
_checkForNonCovariantTypeParameterPositionInRepresentationType(
830-
node, element);
831-
_checkForExtensionTypeRepresentationDependsOnItself(node, element);
832-
_checkForExtensionTypeRepresentationTypeBottom(node, element);
837+
node, declaredFragment);
838+
_checkForExtensionTypeRepresentationDependsOnItself(node, declaredFragment);
839+
_checkForExtensionTypeRepresentationTypeBottom(node, declaredFragment);
833840
_checkForExtensionTypeImplementsDeferred(node);
834-
_checkForExtensionTypeImplementsItself(node, element);
841+
_checkForExtensionTypeImplementsItself(node, declaredFragment);
835842
_checkForExtensionTypeMemberConflicts(
836843
node: node,
837-
element: declarationElement,
844+
element: firstFragment,
838845
);
839846
_checkForExtensionTypeWithAbstractMember(node);
840847
_checkForWrongTypeParameterVarianceInSuperinterfaces();
841848

842-
var interface = _inheritanceManager.getInterface(declarationElement);
849+
var interface = _inheritanceManager.getInterface(firstFragment);
843850
GetterSetterTypesVerifier(
844851
typeSystem: typeSystem,
845852
errorReporter: errorReporter,
846-
).checkExtensionType(element, interface);
853+
).checkExtensionType(declaredFragment, interface);
847854

848855
super.visitExtensionTypeDeclaration(node);
849856
} finally {
@@ -1228,28 +1235,30 @@ class ErrorVerifier extends RecursiveAstVisitor<void>
12281235
void visitMixinDeclaration(covariant MixinDeclarationImpl node) {
12291236
// TODO(scheglov): Verify for all mixin errors.
12301237
try {
1231-
var element = node.declaredElement!;
1238+
var declaredFragment = node.declaredElement!;
1239+
var declaredElement = declaredFragment.element;
1240+
var firstFragment = declaredElement.firstFragment;
12321241

12331242
_checkAugmentations(
12341243
augmentKeyword: node.augmentKeyword,
1235-
element: element,
1244+
element: declaredFragment,
12361245
);
12371246

12381247
_checkMixinAugmentationModifiers(
12391248
augmentKeyword: node.augmentKeyword,
12401249
augmentationNode: node,
1241-
augmentationElement: element,
1250+
augmentationElement: declaredFragment,
12421251
);
12431252

1244-
if (element.augmentedIfReally case var augmented?) {
1253+
if (!identical(firstFragment, declaredFragment)) {
12451254
_checkAugmentationTypeParameters(
12461255
nameToken: node.name,
12471256
typeParameterList: node.typeParameters,
1248-
declarationTypeParameters: augmented.firstFragment.typeParameters,
1257+
declarationTypeParameters: firstFragment.typeParameters,
12491258
);
12501259
}
12511260

1252-
var augmented = element.augmented;
1261+
var augmented = declaredFragment.augmented;
12531262
var declarationElement = augmented.firstFragment;
12541263
_enclosingClass = declarationElement;
12551264

@@ -1267,11 +1276,11 @@ class ErrorVerifier extends RecursiveAstVisitor<void>
12671276
declarationElement, node, onClause, implementsClause);
12681277
}
12691278

1270-
_checkForConflictingClassMembers(element);
1271-
_checkForFinalNotInitializedInClass(element, members);
1279+
_checkForConflictingClassMembers(declaredFragment);
1280+
_checkForFinalNotInitializedInClass(declaredFragment, members);
12721281
_checkForMainFunction1(node.name, declarationElement);
12731282
_checkForWrongTypeParameterVarianceInSuperinterfaces();
1274-
_reportMacroDiagnostics(element);
1283+
_reportMacroDiagnostics(declaredFragment);
12751284
// _checkForBadFunctionUse(node);
12761285
super.visitMixinDeclaration(node);
12771286
} finally {

0 commit comments

Comments
 (0)