Elements. Remove 'augmentedIfReally'. Change-Id: Id6ebeaea49627de09207c96652c600116b71c5bf Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/392500 Reviewed-by: Phil Quitslund <pquitslund@google.com> Reviewed-by: Brian Wilkerson <brianwilkerson@google.com> Commit-Queue: Konstantin Shcheglov <scheglov@google.com>
diff --git a/pkg/analyzer/lib/src/dart/element/element.dart b/pkg/analyzer/lib/src/dart/element/element.dart index 6c5bfa6..6b1a74a 100644 --- a/pkg/analyzer/lib/src/dart/element/element.dart +++ b/pkg/analyzer/lib/src/dart/element/element.dart
@@ -307,15 +307,6 @@ return element; } - AugmentedClassElementImpl? get augmentedIfReally { - if (augmentationTarget != null) { - if (augmented case AugmentedClassElementImpl augmented) { - return augmented; - } - } - return null; - } - @override List<Element2> get children2 { throw StateError('This is a fragment'); @@ -3397,15 +3388,6 @@ return element; } - AugmentedEnumElementImpl? get augmentedIfReally { - if (augmentationTarget != null) { - if (augmented case AugmentedEnumElementImpl augmented) { - return augmented; - } - } - return null; - } - @override List<Element2> get children2 { throw StateError('This is a fragment'); @@ -3665,15 +3647,6 @@ return element; } - AugmentedExtensionElementImpl? get augmentedIfReally { - if (augmentationTarget != null) { - if (augmented case AugmentedExtensionElementImpl augmented) { - return augmented; - } - } - return null; - } - @override List<Element> get children => [ ...super.children, @@ -3794,15 +3767,6 @@ return element; } - AugmentedExtensionTypeElementImpl? get augmentedIfReally { - if (augmentationTarget != null) { - if (augmented case AugmentedExtensionTypeElementImpl augmented) { - return augmented; - } - } - return null; - } - @override List<Element2> get children2 { throw StateError('This is a fragment'); @@ -7736,15 +7700,6 @@ return element; } - AugmentedMixinElementImpl? get augmentedIfReally { - if (augmentationTarget != null) { - if (augmented case AugmentedMixinElementImpl augmented) { - return augmented; - } - } - return null; - } - @override List<Element2> get children2 { throw StateError('This is a fragment');
diff --git a/pkg/analyzer/lib/src/generated/error_verifier.dart b/pkg/analyzer/lib/src/generated/error_verifier.dart index 76fbb03..3180581 100644 --- a/pkg/analyzer/lib/src/generated/error_verifier.dart +++ b/pkg/analyzer/lib/src/generated/error_verifier.dart
@@ -450,35 +450,37 @@ @override void visitClassDeclaration(covariant ClassDeclarationImpl node) { try { - var element = node.declaredElement!; + var declaredFragment = node.declaredElement!; + var declaredElement = declaredFragment.element; + var firstFragment = declaredElement.firstFragment; _checkAugmentations( augmentKeyword: node.augmentKeyword, - element: element, + element: declaredFragment, ); _checkClassAugmentationModifiers( augmentKeyword: node.augmentKeyword, augmentationNode: node, - augmentationElement: element, + augmentationElement: declaredFragment, ); - if (element.augmentedIfReally case var augmented?) { + if (!identical(firstFragment, declaredFragment)) { _checkAugmentationTypeParameters( nameToken: node.name, typeParameterList: node.typeParameters, - declarationTypeParameters: augmented.firstFragment.typeParameters, + declarationTypeParameters: firstFragment.typeParameters, ); } _checkClassAugmentationTargetAlreadyHasExtendsClause( node: node, - augmentationTarget: element.augmentationTarget, + augmentationTarget: declaredFragment.augmentationTarget, ); _isInNativeClass = node.nativeClause != null; - var augmented = element.augmented; + var augmented = declaredFragment.augmented; var declarationElement = augmented.firstFragment; _enclosingClass = declarationElement; @@ -499,7 +501,8 @@ var moreChecks = _checkClassInheritance( declarationElement, node, superclass, withClause, implementsClause); if (moreChecks) { - _checkForNoDefaultSuperConstructorImplicit(element, augmented); + _checkForNoDefaultSuperConstructorImplicit( + declaredFragment, augmented); } } @@ -508,8 +511,8 @@ .addConstructors(errorReporter, augmented, members); } - _checkForConflictingClassMembers(element); - _checkForFinalNotInitializedInClass(element, members); + _checkForConflictingClassMembers(declaredFragment); + _checkForFinalNotInitializedInClass(declaredFragment, members); _checkForBadFunctionUse( superclass: node.extendsClause?.superclass, withClause: node.withClause, @@ -518,7 +521,7 @@ _checkForWrongTypeParameterVarianceInSuperinterfaces(); _checkForMainFunction1(node.name, node.declaredElement!); _checkForMixinClassErrorCodes(node, members, superclass, withClause); - _reportMacroDiagnostics(element); + _reportMacroDiagnostics(declaredFragment); GetterSetterTypesVerifier( typeSystem: typeSystem, @@ -668,30 +671,32 @@ } @override - void visitEnumDeclaration(EnumDeclaration node) { + void visitEnumDeclaration(covariant EnumDeclarationImpl node) { try { - var element = node.declaredElement as EnumElementImpl; + var declaredFragment = node.declaredElement!; + var declaredElement = declaredFragment.element; + var firstFragment = declaredElement.firstFragment; _checkAugmentations( augmentKeyword: node.augmentKeyword, - element: element, + element: declaredFragment, ); - if (element.augmentedIfReally case var augmented?) { + if (!identical(firstFragment, declaredFragment)) { _checkAugmentationTypeParameters( nameToken: node.name, typeParameterList: node.typeParameters, - declarationTypeParameters: augmented.firstFragment.typeParameters, + declarationTypeParameters: firstFragment.typeParameters, ); } - var augmented = element.augmented; + var augmented = declaredFragment.augmented; var declarationElement = augmented.firstFragment; _enclosingClass = declarationElement; _checkForBuiltInIdentifierAsName( node.name, CompileTimeErrorCode.BUILT_IN_IDENTIFIER_AS_TYPE_NAME); - _checkForConflictingEnumTypeVariableErrorCodes(element); + _checkForConflictingEnumTypeVariableErrorCodes(declaredFragment); var implementsClause = node.implementsClause; var withClause = node.withClause; @@ -700,8 +705,8 @@ declarationElement, node, null, withClause, implementsClause); } - if (!element.isAugmentation) { - if (element.augmented.constants.isEmpty) { + if (!declaredFragment.isAugmentation) { + if (declaredFragment.augmented.constants.isEmpty) { errorReporter.atToken( node.name, CompileTimeErrorCode.ENUM_WITHOUT_CONSTANTS, @@ -712,15 +717,15 @@ var members = node.members; libraryContext.constructorFieldsVerifier .addConstructors(errorReporter, augmented, members); - _checkForFinalNotInitializedInClass(element, members); + _checkForFinalNotInitializedInClass(declaredFragment, members); _checkForWrongTypeParameterVarianceInSuperinterfaces(); _checkForMainFunction1(node.name, node.declaredElement!); - _checkForEnumInstantiatedToBoundsIsNotWellBounded(node, element); + _checkForEnumInstantiatedToBoundsIsNotWellBounded(node, declaredFragment); GetterSetterTypesVerifier( typeSystem: typeSystem, errorReporter: errorReporter, - ).checkStaticAccessors(element.accessors); + ).checkStaticAccessors(declaredFragment.accessors); super.visitEnumDeclaration(node); } finally { @@ -753,31 +758,33 @@ @override void visitExtensionDeclaration(covariant ExtensionDeclarationImpl node) { - var element = node.declaredElement!; + var declaredFragment = node.declaredElement!; + var declaredElement = declaredFragment.element; + var firstFragment = declaredElement.firstFragment; _checkAugmentations( augmentKeyword: node.augmentKeyword, - element: element, + element: declaredFragment, ); - if (element.augmentedIfReally case var augmented?) { + if (!identical(firstFragment, declaredFragment)) { if (node.name case var nameToken?) { _checkAugmentationTypeParameters( nameToken: nameToken, typeParameterList: node.typeParameters, - declarationTypeParameters: augmented.firstFragment.typeParameters, + declarationTypeParameters: firstFragment.typeParameters, ); } } - _enclosingExtension = element; + _enclosingExtension = declaredFragment; _checkForConflictingExtensionTypeVariableErrorCodes(); - _checkForFinalNotInitializedInClass(element, node.members); + _checkForFinalNotInitializedInClass(declaredFragment, node.members); GetterSetterTypesVerifier( typeSystem: typeSystem, errorReporter: errorReporter, - ).checkExtension(element); + ).checkExtension(declaredFragment); var name = node.name; if (name != null) { @@ -793,57 +800,57 @@ covariant ExtensionTypeDeclarationImpl node, ) { try { - var element = node.declaredElement!; - var augmented = element.augmented; - var declarationElement = augmented.firstFragment; + var declaredFragment = node.declaredElement!; + var declaredElement = declaredFragment.augmented; + var firstFragment = declaredElement.firstFragment; _checkAugmentations( augmentKeyword: node.augmentKeyword, - element: element, + element: declaredFragment, ); - if (element.augmentedIfReally case var augmented?) { + if (!identical(firstFragment, declaredFragment)) { _checkAugmentationTypeParameters( nameToken: node.name, typeParameterList: node.typeParameters, - declarationTypeParameters: augmented.firstFragment.typeParameters, + declarationTypeParameters: firstFragment.typeParameters, ); } - _enclosingClass = declarationElement; + _enclosingClass = firstFragment; _checkForBuiltInIdentifierAsName(node.name, CompileTimeErrorCode.BUILT_IN_IDENTIFIER_AS_EXTENSION_TYPE_NAME); - _checkForConflictingExtensionTypeTypeVariableErrorCodes(element); + _checkForConflictingExtensionTypeTypeVariableErrorCodes(declaredFragment); var members = node.members; _checkForRepeatedType( - libraryContext.setOfImplements(declarationElement), + libraryContext.setOfImplements(firstFragment), node.implementsClause?.interfaces, CompileTimeErrorCode.IMPLEMENTS_REPEATED, ); - _checkForConflictingClassMembers(element); + _checkForConflictingClassMembers(declaredFragment); _checkForConflictingGenerics(node); libraryContext.constructorFieldsVerifier - .addConstructors(errorReporter, augmented, members); + .addConstructors(errorReporter, declaredElement, members); _checkForNonCovariantTypeParameterPositionInRepresentationType( - node, element); - _checkForExtensionTypeRepresentationDependsOnItself(node, element); - _checkForExtensionTypeRepresentationTypeBottom(node, element); + node, declaredFragment); + _checkForExtensionTypeRepresentationDependsOnItself(node, declaredFragment); + _checkForExtensionTypeRepresentationTypeBottom(node, declaredFragment); _checkForExtensionTypeImplementsDeferred(node); - _checkForExtensionTypeImplementsItself(node, element); + _checkForExtensionTypeImplementsItself(node, declaredFragment); _checkForExtensionTypeMemberConflicts( node: node, - element: declarationElement, + element: firstFragment, ); _checkForExtensionTypeWithAbstractMember(node); _checkForWrongTypeParameterVarianceInSuperinterfaces(); - var interface = _inheritanceManager.getInterface(declarationElement); + var interface = _inheritanceManager.getInterface(firstFragment); GetterSetterTypesVerifier( typeSystem: typeSystem, errorReporter: errorReporter, - ).checkExtensionType(element, interface); + ).checkExtensionType(declaredFragment, interface); super.visitExtensionTypeDeclaration(node); } finally { @@ -1228,28 +1235,30 @@ void visitMixinDeclaration(covariant MixinDeclarationImpl node) { // TODO(scheglov): Verify for all mixin errors. try { - var element = node.declaredElement!; + var declaredFragment = node.declaredElement!; + var declaredElement = declaredFragment.element; + var firstFragment = declaredElement.firstFragment; _checkAugmentations( augmentKeyword: node.augmentKeyword, - element: element, + element: declaredFragment, ); _checkMixinAugmentationModifiers( augmentKeyword: node.augmentKeyword, augmentationNode: node, - augmentationElement: element, + augmentationElement: declaredFragment, ); - if (element.augmentedIfReally case var augmented?) { + if (!identical(firstFragment, declaredFragment)) { _checkAugmentationTypeParameters( nameToken: node.name, typeParameterList: node.typeParameters, - declarationTypeParameters: augmented.firstFragment.typeParameters, + declarationTypeParameters: firstFragment.typeParameters, ); } - var augmented = element.augmented; + var augmented = declaredFragment.augmented; var declarationElement = augmented.firstFragment; _enclosingClass = declarationElement; @@ -1267,11 +1276,11 @@ declarationElement, node, onClause, implementsClause); } - _checkForConflictingClassMembers(element); - _checkForFinalNotInitializedInClass(element, members); + _checkForConflictingClassMembers(declaredFragment); + _checkForFinalNotInitializedInClass(declaredFragment, members); _checkForMainFunction1(node.name, declarationElement); _checkForWrongTypeParameterVarianceInSuperinterfaces(); - _reportMacroDiagnostics(element); + _reportMacroDiagnostics(declaredFragment); // _checkForBadFunctionUse(node); super.visitMixinDeclaration(node); } finally {