Open
Description
Here, the call to f should be valid and inferrable as Cloneable<T>
.
class Clonable<T> {}
class SubClonable<T> extends Clonable<T> {
T m(T t) => t;
}
void f<T extends Clonable<T>>(T object) {
if (object is SubClonable<T>) {
f(object);
}
}
However it fails in analyzer and CFE. This is the analyzer ticket for this issue. (CFE is #35800)
It's critical to note that object
is promoted to type T' extends SubCloneable<T>
. So if the analyzer attempts to infer SubClonable<T>
for T
in f(object)
, then that will fail. However, it should be possible to infer Clonable, which in fact works when typed explicitly.
May be related to #35100