File tree Expand file tree Collapse file tree 3 files changed +12
-7
lines changed Expand file tree Collapse file tree 3 files changed +12
-7
lines changed Original file line number Diff line number Diff line change @@ -11,9 +11,7 @@ lib/src/rules/prefer_initializing_formals.dart
1111lib/src/rules/public_member_api_docs.dart
1212lib/src/rules/unnecessary_overrides.dart
1313lib/src/rules/use_build_context_synchronously.dart
14- lib/src/rules/use_key_in_widget_constructors.dart
1514lib/src/rules/use_late_for_private_fields_and_variables.dart
16- lib/src/rules/use_setters_to_change_properties.dart
1715lib/src/util/dart_type_utilities.dart
1816lib/src/util/flutter_utils.dart
1917lib/src/util/leak_detector_visitor.dart
Original file line number Diff line number Diff line change @@ -371,6 +371,12 @@ extension ElementExtension on Element {
371371}
372372
373373extension ElementExtension2 on Element2 ? {
374+ Element2 ? get canonicalElement2 => switch (this ) {
375+ GetterElement (: var variable3) => variable3,
376+ SetterElement (: var variable3) => variable3,
377+ _ => this ,
378+ };
379+
374380 bool get isDartCorePrint {
375381 var self = this ;
376382 return self is TopLevelFunctionElement &&
Original file line number Diff line number Diff line change 55import 'package:analyzer/dart/ast/ast.dart' ;
66import 'package:analyzer/dart/ast/token.dart' ;
77import 'package:analyzer/dart/ast/visitor.dart' ;
8- import 'package:analyzer/dart/element/element .dart' ;
8+ import 'package:analyzer/dart/element/element2 .dart' ;
99import 'package:analyzer/dart/element/type.dart' ;
1010
1111import '../analyzer.dart' ;
@@ -50,10 +50,11 @@ class _Visitor extends SimpleAstVisitor<void> {
5050 void checkExpression (Expression expression) {
5151 if (expression is AssignmentExpression &&
5252 expression.operator .type == TokenType .EQ ) {
53- var leftOperand = expression.writeElement? .canonicalElement;
54- var rightOperand = expression.rightHandSide.canonicalElement;
55- var parameterElement = node.declaredElement? .parameters.first;
56- if (rightOperand == parameterElement && leftOperand is FieldElement ) {
53+ var leftOperand = expression.writeElement2? .canonicalElement2;
54+ var rightOperand = expression.rightHandSide.canonicalElement2;
55+ var parameterElement =
56+ node.declaredFragment? .element.formalParameters.first;
57+ if (rightOperand == parameterElement && leftOperand is FieldElement2 ) {
5758 rule.reportLintForToken (node.name);
5859 }
5960 }
You can’t perform that action at this time.
0 commit comments