Skip to content

Commit c2b9bdc

Browse files
pqCommit Queue
authored and
Commit Queue
committed
[element model] migrate avoid_returning_this
Bug: https://github.com/dart-lang/linter/issues/5099 Change-Id: Ia746475aaa29bae8be14a8c408adf728e77e015e Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/390081 Auto-Submit: Phil Quitslund <[email protected]> Reviewed-by: Brian Wilkerson <[email protected]> Commit-Queue: Brian Wilkerson <[email protected]> Commit-Queue: Phil Quitslund <[email protected]>
1 parent 5572900 commit c2b9bdc

File tree

2 files changed

+8
-7
lines changed

2 files changed

+8
-7
lines changed

pkg/linter/analyzer_use_new_elements.txt

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,7 @@ lib/src/rules/avoid_relative_lib_imports.dart
3131
lib/src/rules/avoid_return_types_on_setters.dart
3232
lib/src/rules/avoid_returning_null.dart
3333
lib/src/rules/avoid_returning_null_for_future.dart
34+
lib/src/rules/avoid_returning_this.dart
3435
lib/src/rules/avoid_shadowing_type_parameters.dart
3536
lib/src/rules/avoid_single_cascade_in_expression_statements.dart
3637
lib/src/rules/avoid_slow_async_io.dart
@@ -346,6 +347,8 @@ test/rules/prefer_inlined_adds_test.dart
346347
test/rules/prefer_int_literals_test.dart
347348
test/rules/prefer_interpolation_to_compose_strings_test.dart
348349
test/rules/prefer_is_empty_test.dart
350+
test/rules/prefer_is_not_empty_test.dart
351+
test/rules/prefer_is_not_operator_test.dart
349352
test/rules/prefer_iterable_whereType_test.dart
350353
test/rules/prefer_mixin_test.dart
351354
test/rules/prefer_null_aware_method_calls_test.dart
@@ -442,9 +445,6 @@ test/verify_reflective_test_suites_test.dart
442445
test_data/rules/no_default_cases.dart
443446
test_data/rules/overridden_fields.dart
444447
test_data/rules/prefer_const_declarations.dart
445-
test_data/rules/prefer_final_fields.dart
446-
test_data/rules/prefer_is_not_empty.dart
447-
test_data/rules/prefer_is_not_operator.dart
448448
test_data/rules/prefer_void_to_null.dart
449449
test_data/rules/require_trailing_commas.dart
450450
test_data/rules/type_init_formals.dart

pkg/linter/lib/src/rules/avoid_returning_this.dart

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2,9 +2,9 @@
22
// for details. All rights reserved. Use of this source code is governed by a
33
// BSD-style license that can be found in the LICENSE file.
44

5-
import 'package:analyzer/dart/ast/ast.dart';
65
import 'package:analyzer/dart/ast/visitor.dart';
76
import 'package:analyzer/dart/element/type.dart';
7+
import 'package:analyzer/src/dart/ast/ast.dart'; // ignore: implementation_imports
88

99
import '../analyzer.dart';
1010
import '../extensions.dart';
@@ -79,10 +79,11 @@ class _Visitor extends SimpleAstVisitor<void> {
7979
return;
8080
}
8181

82-
var returnType = node.declaredElement?.returnType;
82+
var returnType = node.declaredFragment?.element.returnType;
8383
if (returnType is InterfaceType &&
84-
// ignore: cast_nullable_to_non_nullable
85-
returnType.element == (parent as Declaration).declaredElement) {
84+
returnType.element3 ==
85+
// ignore: cast_nullable_to_non_nullable
86+
(parent as FragmentDeclaration).declaredFragment?.element) {
8687
} else {
8788
return;
8889
}

0 commit comments

Comments
 (0)