Open
Description
Would it be possible to infer type bounds in as checks?
Consider the following example:
class A<T extends Object> {
Object? get value => null;
}
class B<T extends Object> extends A<T> {
@override
final T value;
B(this.value);
}
void example() {
final A<int> a = B<int>(123);
if (a is B) { // inferred as `a is B<Object>`. It would be nice if this would be inferred as B<int>
final x = a.value; // inferred as `final Object? x` due to `a` not being promoted to `B<int>` and staying `A<int>`.
}
if (a is B<int>) { // manually specifying `B<int>` promotes `a` to `B<int>` from `A<int>`
final x = a.value; // which means `x` is inferred as `int`
}
}