Files
sdk/pkg/analysis_server
Sam Rawlins 5a6b815789 analyzer: Report a warning when a Future.then onError handler returns the wrong type.
Fixes https://github.com/dart-lang/sdk/issues/54927

Generally this warning reports these cases:

The function expression has an unassignable return type:

```
void f(Future<int> future) {
  future.then((_) => 0, onError: (e, st) => 'c');
}
```

The function has an unassignable return type

```
void f(Future<int> future, String Function(dynamic, StackTrace) cb) {
  future.then<int>((_) => 1, onError: cb);
}
```

The block function body has an unassignable return type or is missing a return type:

```
void f(Future<int> future) {
  future.then((_) => 0, onError: (e, st) {
    if (1 == 2) {
      return;
    } else {
      return 0.5;
    }
  });
}
```

Change-Id: I5d67ae35109a874543af01936f13256ff457b35b
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/498240
Reviewed-by: Konstantin Shcheglov <scheglov@google.com>
Reviewed-by: Brian Wilkerson <brianwilkerson@google.com>
Commit-Queue: Samuel Rawlins <srawlins@google.com>
2026-04-29 05:00:59 -07:00
..

analysis_server

A long-running process that provides analysis results to other tools.

The analysis server is designed to provide on-going analysis of one or more code bases as those code bases are changing.

Using the server

The analysis server is not intended to be used stand-alone, and therefore does not have a human-friendly user interface.

Clients (typically tools, such as an editor) are expected to run the analysis server in a separate process and communicate with it using a JSON protocol. The original protocol is specified in the file analysis_server/doc/api.html and Language Server Protocol support is documented in tool/lsp_spec/README.md.

Features and bugs

Please file feature requests and bugs at the issue tracker.