Skip to content

Commit

Permalink
[element model] migrate unnecessary_statements
Browse files Browse the repository at this point in the history
Bug: dart-lang/linter#5099
Change-Id: Ia91e1dc12038414b62c4975de3c2ee4769017b5d
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/387129
Reviewed-by: Brian Wilkerson <[email protected]>
Commit-Queue: Phil Quitslund <[email protected]>
  • Loading branch information
pq authored and Commit Queue committed Sep 27, 2024
1 parent ae182d2 commit 01cc385
Showing 1 changed file with 7 additions and 7 deletions.
14 changes: 7 additions & 7 deletions pkg/linter/lib/src/rules/unnecessary_statements.dart
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@

import 'package:analyzer/dart/ast/ast.dart';
import 'package:analyzer/dart/ast/visitor.dart';
import 'package:analyzer/dart/element/element.dart';
import 'package:analyzer/dart/element/element2.dart';
import 'package:analyzer/dart/element/type.dart';

import '../analyzer.dart';
Expand Down Expand Up @@ -127,8 +127,8 @@ class _ReportNoClearEffectVisitor extends UnifyingAstVisitor {
void visitPrefixedIdentifier(PrefixedIdentifier node) {
// Allow getters; getters with side effects were the main cause of false
// positives.
var element = node.identifier.staticElement;
if (element is PropertyAccessorElement && !element.isSynthetic) {
var element = node.identifier.element;
if (element is GetterElement && !element.isSynthetic) {
return;
}

Expand All @@ -148,8 +148,8 @@ class _ReportNoClearEffectVisitor extends UnifyingAstVisitor {
void visitPropertyAccess(PropertyAccess node) {
// Allow getters; previously getters with side effects were the main cause
// of false positives.
var element = node.propertyName.staticElement;
if (element is PropertyAccessorElement && !element.isSynthetic) {
var element = node.propertyName.element;
if (element is GetterElement && !element.isSynthetic) {
return;
}

Expand All @@ -165,8 +165,8 @@ class _ReportNoClearEffectVisitor extends UnifyingAstVisitor {
void visitSimpleIdentifier(SimpleIdentifier node) {
// Allow getter (in this case with an implicit `this.`); previously, getters
// with side effects were the main cause of false positives.
var element = node.staticElement;
if (element is PropertyAccessorElement && !element.isSynthetic) {
var element = node.element;
if (element is GetterElement && !element.isSynthetic) {
return;
}

Expand Down

0 comments on commit 01cc385

Please sign in to comment.