Skip to content

Commit 265b6c8

Browse files
pqCommit Queue
authored andcommitted
[element model] migrate await_only_futures
Bug: https://github.com/dart-lang/linter/issues/5099 Change-Id: I280d5b1a93a0944208c976a51e6d0be007e2e4aa Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/387325 Commit-Queue: Brian Wilkerson <[email protected]> Auto-Submit: Phil Quitslund <[email protected]> Reviewed-by: Brian Wilkerson <[email protected]>
1 parent 84e15e9 commit 265b6c8

File tree

2 files changed

+6
-3
lines changed

2 files changed

+6
-3
lines changed

pkg/analyzer/lib/src/dart/element/type.dart

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,10 @@ class DynamicTypeImpl extends TypeImpl
4343
DynamicTypeImpl._();
4444

4545
@override
46-
Element2? get element3 => (element as Fragment).element;
46+
Element2? get element3 => switch (element) {
47+
Fragment(:var element) => element,
48+
_ => null,
49+
};
4750

4851
@override
4952
int get hashCode => 1;

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

Lines changed: 2 additions & 2 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';
@@ -41,7 +41,7 @@ class _Visitor extends SimpleAstVisitor<void> {
4141

4242
var type = node.expression.staticType;
4343
if (!(type == null ||
44-
type.element is ExtensionTypeElement ||
44+
type.element3 is ExtensionTypeElement2 ||
4545
type.isDartAsyncFuture ||
4646
type is DynamicType ||
4747
type is InvalidType ||

0 commit comments

Comments
 (0)