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';
6
6
import 'package:analysis_server_plugin/edit/dart/correction_producer.dart' ;
7
7
import 'package:analyzer/dart/ast/ast.dart' ;
8
8
import 'package:analyzer/dart/ast/precedence.dart' ;
9
+ import 'package:analyzer/dart/element/nullability_suffix.dart' ;
9
10
import 'package:analyzer/dart/element/type.dart' ;
10
11
import 'package:analyzer_plugin/utilities/change_builder/change_builder_core.dart' ;
11
12
import 'package:analyzer_plugin/utilities/fixes/fixes.dart' ;
@@ -79,6 +80,12 @@ class WrapInUnawaited extends ResolvedCorrectionProducer {
79
80
if (type.isDartAsyncFutureOr) {
80
81
return true ;
81
82
}
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
+ );
83
90
}
84
91
}
Original file line number Diff line number Diff line change @@ -105,7 +105,22 @@ class C {
105
105
}
106
106
107
107
void 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;
109
124
}
110
125
''' );
111
126
await assertNoFix ();
@@ -224,6 +239,25 @@ Future<void> f() async {
224
239
''' );
225
240
}
226
241
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
+
227
261
Future <void > test_subTypeOfFuture () async {
228
262
await resolveTestCode ('''
229
263
abstract class MyFuture implements Future<void> {}
You can’t perform that action at this time.
0 commit comments