-
Notifications
You must be signed in to change notification settings - Fork 1.7k
Open
Labels
P2A bug or feature request we're likely to work onA bug or feature request we're likely to work onarea-devexpFor issues related to the analysis server, IDE support, linter, `dart fix`, and diagnostic messages.For issues related to the analysis server, IDE support, linter, `dart fix`, and diagnostic messages.devexp-linterIssues with the analyzer's support for the linter packageIssues with the analyzer's support for the linter packagelinter-false-positiveIssues related to lint rules that report a problem when it isn't a problem.Issues related to lint rules that report a problem when it isn't a problem.type-enhancementA request for a change that isn't a bugA request for a change that isn't a bug
Description
@useResult is used to ensure that the result returned from a function is used. But it's current implementation is 'mustSetToVariable'. Usually those are 1-1, however there is a case where that is not true. In the case of a function that returns a Future, the Future can be used, without it being set to a variable.
EX:
dart```
import 'package:meta/meta.dart';
@useResult
Future testFuture() async {
await Future.delayed(Duration(seconds: 1));
return 1;
}
void main() async {
await testFuture();
}
In this example, the testFuture's return value has been 'used'. We have waited for the returned future to complete. A copy of the functionality like so
dart```
void main() async {
final future = testFuture();
await future;
}
no longer shows the warning, but the outcome is the same.
I am attempting to argue to not show the warning if the result of a function is a Future and that Future is awaited.
FMorschel
Metadata
Metadata
Assignees
Labels
P2A bug or feature request we're likely to work onA bug or feature request we're likely to work onarea-devexpFor issues related to the analysis server, IDE support, linter, `dart fix`, and diagnostic messages.For issues related to the analysis server, IDE support, linter, `dart fix`, and diagnostic messages.devexp-linterIssues with the analyzer's support for the linter packageIssues with the analyzer's support for the linter packagelinter-false-positiveIssues related to lint rules that report a problem when it isn't a problem.Issues related to lint rules that report a problem when it isn't a problem.type-enhancementA request for a change that isn't a bugA request for a change that isn't a bug