Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

@useResult annotation doesn't work when Callable class is invoked #48913

Closed
maRci002 opened this issue Apr 28, 2022 · 1 comment
Closed

@useResult annotation doesn't work when Callable class is invoked #48913

maRci002 opened this issue Apr 28, 2022 · 1 comment
Labels
area-analyzer Use area-analyzer for Dart analyzer issues, including the analysis server and code completion. P2 A bug or feature request we're likely to work on type-bug Incorrect behavior (everything from a crash to more subtle misbehavior)

Comments

@maRci002
Copy link

@useResult annotation works fine when a callable class' instance is invoked explicitly by calling instance.call(...) however when the instance is invoked implicitly instance(...) the anyalazer won't complain.

class Foo {
  const Foo();

  @useResult
  int call() {
    return 42;
  }
}

void main() {
  final foo = const Foo();
  foo.call();
  foo(); // BAD: return value is silently ignored
}

dart --version

Dart SDK version: 2.16.2 (stable) (Tue Mar 22 13:15:13 2022 +0100) on "windows_x64"

@lrhn lrhn added area-analyzer Use area-analyzer for Dart analyzer issues, including the analysis server and code completion. type-bug Incorrect behavior (everything from a crash to more subtle misbehavior) labels Apr 28, 2022
@asashour
Copy link
Contributor

https://dart-review.googlesource.com/c/sdk/+/242868

@pq pq added the P2 A bug or feature request we're likely to work on label May 3, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
area-analyzer Use area-analyzer for Dart analyzer issues, including the analysis server and code completion. P2 A bug or feature request we're likely to work on type-bug Incorrect behavior (everything from a crash to more subtle misbehavior)
Projects
None yet
Development

No branches or pull requests

4 participants