sdk
sdk copied to clipboard
[analyzer] Apparently no checks are performed for member accesses on an object of type `X extends FutureOr<X>`
Consider the following program:
import 'dart:async';
void f<X extends FutureOr<X>>(X x) {
x.asStream(); // A member from the interface of `Future`.
x.whatever; // A non-member of all classes nearby.
}
void main() {}
This program is accepted by the analyzer (dart analyze from 2.19.0-32.0.dev) with no issues. It looks like the bound X extends FutureOr<X> creates confusion about how to check expressions whose type involves X.
The interface of X should be taken from the bound, and the interface of FutureOr<T> is the interface of Object, for any T.