Skip to content

Commit c69898a

Browse files
pqCommit Queue
authored and
Commit Queue
committed
[element model] migrate discarded_futures
Bug: https://github.com/dart-lang/linter/issues/5099 Change-Id: I1034c5daf88a33f2d8a18fa8dc01d9e2de10e942 Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/387321 Commit-Queue: Phil Quitslund <[email protected]> Reviewed-by: Brian Wilkerson <[email protected]>
1 parent 01cc385 commit c69898a

File tree

1 file changed

+5
-5
lines changed

1 file changed

+5
-5
lines changed

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

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44

55
import 'package:analyzer/dart/ast/ast.dart';
66
import 'package:analyzer/dart/ast/visitor.dart';
7-
import 'package:analyzer/dart/element/element.dart';
7+
import 'package:analyzer/dart/element/element2.dart';
88
import 'package:analyzer/dart/element/type.dart';
99

1010
import '../analyzer.dart';
@@ -54,7 +54,7 @@ class _InvocationVisitor extends RecursiveAstVisitor<void> {
5454

5555
@override
5656
void visitMethodInvocation(MethodInvocation node) {
57-
if (node.methodName.staticElement.isDartAsyncUnawaited) return;
57+
if (node.methodName.element.isDartAsyncUnawaited) return;
5858
if (node.staticInvokeType.isFuture) {
5959
rule.reportLint(node.methodName);
6060
}
@@ -127,11 +127,11 @@ extension on DartType? {
127127
}
128128
}
129129

130-
extension ElementExtension on Element? {
130+
extension ElementExtension on Element2? {
131131
bool get isDartAsyncUnawaited {
132132
var self = this;
133-
return self is FunctionElement &&
133+
return self is TopLevelFunctionElement &&
134134
self.name == 'unawaited' &&
135-
self.library.isDartAsync;
135+
(self.library2?.isDartAsync ?? false);
136136
}
137137
}

0 commit comments

Comments
 (0)