Move the check for INVALID_SEALED to the BestPracticesVerifier

Change-Id: I974196f7cd1c2b7c24df1d759774faed9f8a2581
Reviewed-on: https://dart-review.googlesource.com/c/87705
Commit-Queue: Samuel Rawlins <srawlins@google.com>
Reviewed-by: Konstantin Shcheglov <scheglov@google.com>
This commit is contained in:
Sam Rawlins 2018-12-19 23:40:06 +00:00 committed by commit-bot@chromium.org
parent ac506a9d92
commit f69aabdb62
2 changed files with 8 additions and 8 deletions

View file

@ -96,13 +96,6 @@ class ConstantVerifier extends RecursiveAstVisitor<void> {
// arguments should be constants
_validateConstantArguments(argumentList);
}
if (node.elementAnnotation?.isSealed == true &&
!(node.parent is ClassDeclaration ||
node.parent is ClassTypeAlias ||
node.parent is MixinDeclaration)) {
_errorReporter.reportErrorForNode(
HintCode.INVALID_SEALED_ANNOTATION, node.parent, [node.element.name]);
}
}
@override

View file

@ -298,8 +298,8 @@ class BestPracticesVerifier extends RecursiveAstVisitor<void> {
void visitAnnotation(Annotation node) {
ElementAnnotation element =
resolutionMap.elementAnnotationForAnnotation(node);
AstNode parent = node.parent;
if (element?.isFactory == true) {
AstNode parent = node.parent;
if (parent is MethodDeclaration) {
_checkForInvalidFactory(parent);
} else {
@ -313,6 +313,13 @@ class BestPracticesVerifier extends RecursiveAstVisitor<void> {
HintCode.INVALID_IMMUTABLE_ANNOTATION, node, []);
}
}
if (node.elementAnnotation?.isSealed == true &&
!(parent is ClassDeclaration ||
parent is ClassTypeAlias ||
parent is MixinDeclaration)) {
_errorReporter.reportErrorForNode(
HintCode.INVALID_SEALED_ANNOTATION, node.parent, [node.element.name]);
}
super.visitAnnotation(node);
}