Skip to content

Commit 7188447

Browse files
scheglovCommit Queue
authored andcommitted
Elements. Tweak nested getter/setter if(s) into switch.
Change-Id: Ie5136c282d4d9e670970284c5a0415791edbe28b Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/410860 Commit-Queue: Konstantin Shcheglov <[email protected]> Reviewed-by: Phil Quitslund <[email protected]>
1 parent a0302a6 commit 7188447

File tree

1 file changed

+8
-9
lines changed

1 file changed

+8
-9
lines changed

pkg/analyzer/lib/src/error/override_verifier.dart

Lines changed: 8 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -61,23 +61,22 @@ class OverrideVerifier extends RecursiveAstVisitor<void> {
6161
void visitMethodDeclaration(MethodDeclaration node) {
6262
var element = node.declaredFragment!.element;
6363
if (element.metadata2.hasOverride && !_isOverride(element)) {
64-
if (element is MethodElement2) {
65-
_errorReporter.atToken(
66-
node.name,
67-
WarningCode.OVERRIDE_ON_NON_OVERRIDING_METHOD,
68-
);
69-
} else if (element is PropertyAccessorElement2) {
70-
if (element is GetterElement) {
64+
switch (element) {
65+
case MethodElement2():
66+
_errorReporter.atToken(
67+
node.name,
68+
WarningCode.OVERRIDE_ON_NON_OVERRIDING_METHOD,
69+
);
70+
case GetterElement():
7171
_errorReporter.atToken(
7272
node.name,
7373
WarningCode.OVERRIDE_ON_NON_OVERRIDING_GETTER,
7474
);
75-
} else {
75+
case SetterElement():
7676
_errorReporter.atToken(
7777
node.name,
7878
WarningCode.OVERRIDE_ON_NON_OVERRIDING_SETTER,
7979
);
80-
}
8180
}
8281
}
8382
}

0 commit comments

Comments
 (0)