-
Couldn't load subscription status.
- Fork 1.7k
Description
In strong mode type inference (see https://github.com/dart-lang/sdk/pull/29371/files), we need to be able to handle type promotions like this:
class A {}
class B extends A {
void foo() { ... }
}
class C<T extends A> {
f(T t) { ... }
h(T t) {
if (t is B) {
f(t); // ok because t has type T
t.foo(); // ok because t extends B
}
}
}
In order for this to work, we need to be able to represent the type of t within the "if" block as "T extends B". Currently kernel can't do this, because currently a TypeParameterType just points to the type parameter, which can only have a single bound.
Note that we need to be able to recognize the difference between a type that has a promoted bound and a type that has its original bound, so what we probably want to do is add a nullable bound field to TypeParameterType--we'll use null to represent the (typical) case of a type variable with a non-promoted bound, and a non-null value to represent the case of a type variable with a promoted bound.