Skip to content

Commit

Permalink
Augment. Report AUGMENTATION_WITHOUT_DECLARATION in more places.
Browse files Browse the repository at this point in the history
Change-Id: I2e38a31f987788e97cb61f0985aad0b6ef861582
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/364600
Commit-Queue: Konstantin Shcheglov <[email protected]>
Reviewed-by: Brian Wilkerson <[email protected]>
Reviewed-by: Phil Quitslund <[email protected]>
  • Loading branch information
scheglov authored and Commit Queue committed Apr 25, 2024
1 parent 5c3cad7 commit 6e7aca7
Show file tree
Hide file tree
Showing 4 changed files with 449 additions and 7 deletions.
14 changes: 9 additions & 5 deletions pkg/analyzer/lib/src/error/best_practices_verifier.dart
Original file line number Diff line number Diff line change
Expand Up @@ -396,16 +396,20 @@ class BestPracticesVerifier extends RecursiveAstVisitor<void> {
var element = field.declaredElement;
if (element is PropertyAccessorElement || element is FieldElement) {
Name name = Name(_currentLibrary.source.uri, element!.name);
Element enclosingElement = element.enclosingElement!;
if (enclosingElement is InterfaceElement) {
var enclosingElement = element.enclosingElement!;
var enclosingDeclaration = enclosingElement is InstanceElement
? enclosingElement.augmented.declaration
: enclosingElement;
if (enclosingDeclaration is InterfaceElement) {
var overridden = _inheritanceManager
.getMember2(enclosingElement, name, forSuper: true);
.getMember2(enclosingDeclaration, name, forSuper: true);
// Check for a setter.
if (overridden == null) {
Name setterName =
Name(_currentLibrary.source.uri, '${element.name}=');
overridden = _inheritanceManager
.getMember2(enclosingElement, setterName, forSuper: true);
overridden = _inheritanceManager.getMember2(
enclosingDeclaration, setterName,
forSuper: true);
}
return overridden;
}
Expand Down
5 changes: 3 additions & 2 deletions pkg/analyzer/lib/src/generated/element_resolver.dart
Original file line number Diff line number Diff line change
Expand Up @@ -307,12 +307,13 @@ class ElementResolver {
// TODO(brianwilkerson): Report this error.
return;
}
var enclosingAugmented = enclosingClass.augmented;
ConstructorElement? element;
var name = node.constructorName;
if (name == null) {
element = enclosingClass.unnamedConstructor;
element = enclosingAugmented.unnamedConstructor;
} else {
element = enclosingClass.getNamedConstructor(name.name);
element = enclosingAugmented.getNamedConstructor(name.name);
}
if (element == null) {
// TODO(brianwilkerson): Report this error and decide what element to
Expand Down
17 changes: 17 additions & 0 deletions pkg/analyzer/lib/src/generated/error_verifier.dart
Original file line number Diff line number Diff line change
Expand Up @@ -640,6 +640,11 @@ class ErrorVerifier extends RecursiveAstVisitor<void>
var element = node.declaredElement as EnumElementImpl;

var augmented = element.augmented;
_checkAugmentations(
augmentKeyword: node.augmentKeyword,
element: element,
);

_enclosingClass = element;
_duplicateDefinitionVerifier.checkEnum(node);

Expand Down Expand Up @@ -707,6 +712,12 @@ class ErrorVerifier extends RecursiveAstVisitor<void>
@override
void visitExtensionDeclaration(covariant ExtensionDeclarationImpl node) {
var element = node.declaredElement!;

_checkAugmentations(
augmentKeyword: node.augmentKeyword,
element: element,
);

_enclosingExtension = element;
_duplicateDefinitionVerifier.checkExtension(node);
_checkForConflictingExtensionTypeVariableErrorCodes();
Expand Down Expand Up @@ -734,6 +745,12 @@ class ErrorVerifier extends RecursiveAstVisitor<void>
var element = node.declaredElement!;
var augmented = element.augmented;
var declarationElement = augmented.declaration;

_checkAugmentations(
augmentKeyword: node.augmentKeyword,
element: element,
);

_enclosingClass = declarationElement;

_checkForBuiltInIdentifierAsName(node.name,
Expand Down
Loading

0 comments on commit 6e7aca7

Please sign in to comment.