File tree Expand file tree Collapse file tree 2 files changed +43
-2
lines changed
lib/src/services/correction/dart
test/src/services/correction/fix Expand file tree Collapse file tree 2 files changed +43
-2
lines changed Original file line number Diff line number Diff line change @@ -6,6 +6,7 @@ import 'package:analysis_server/src/services/correction/fix.dart';
66import 'package:analysis_server_plugin/edit/dart/correction_producer.dart' ;
77import 'package:analyzer/dart/ast/ast.dart' ;
88import 'package:analyzer/dart/ast/precedence.dart' ;
9+ import 'package:analyzer/dart/element/nullability_suffix.dart' ;
910import 'package:analyzer/dart/element/type.dart' ;
1011import 'package:analyzer_plugin/utilities/change_builder/change_builder_core.dart' ;
1112import 'package:analyzer_plugin/utilities/fixes/fixes.dart' ;
@@ -79,6 +80,12 @@ class WrapInUnawaited extends ResolvedCorrectionProducer {
7980 if (type.isDartAsyncFutureOr) {
8081 return true ;
8182 }
82- return typeSystem.isAssignableTo (type, typeProvider.futureDynamicType);
83+ return typeSystem.isAssignableTo (
84+ type,
85+ typeProvider.futureElement.instantiate (
86+ typeArguments: [typeProvider.dynamicType],
87+ nullabilitySuffix: NullabilitySuffix .question,
88+ ),
89+ );
8390 }
8491}
Original file line number Diff line number Diff line change @@ -105,7 +105,22 @@ class C {
105105}
106106
107107void main() async {
108- C()..something();
108+ C()..something();
109+ }
110+ ''' );
111+ await assertNoFix ();
112+ }
113+
114+ Future <void > test_cascadeExpression_getter () async {
115+ await resolveTestCode ('''
116+ class C {
117+ Future<String> get something {
118+ return Future.value('hello');
119+ }
120+ }
121+
122+ void f(C Function() fn) async {
123+ fn()..something;
109124}
110125''' );
111126 await assertNoFix ();
@@ -224,6 +239,25 @@ Future<void> f() async {
224239''' );
225240 }
226241
242+ Future <void > test_nullableFuture () async {
243+ await resolveTestCode ('''
244+ Future<void> f() async {
245+ g();
246+ }
247+
248+ Future<void>? g() async { }
249+ ''' );
250+ await assertHasFix ('''
251+ import 'dart:async';
252+
253+ Future<void> f() async {
254+ unawaited(g());
255+ }
256+
257+ Future<void>? g() async { }
258+ ''' );
259+ }
260+
227261 Future <void > test_subTypeOfFuture () async {
228262 await resolveTestCode ('''
229263abstract class MyFuture implements Future<void> {}
You can’t perform that action at this time.
0 commit comments