Closed
Description
Consider the following program:
class A<X extends A<X>> {}
class B extends A<B> {}
class C extends B {}
void f<X extends A<X>>(X x) {}
void main() {
f(B()); // OK.
f(C()); // Inference fails, compile-time error.
f<B>(C()); // OK.
}
Most likely, the inference could succeed in choosing the type argument B
even in the case where the actual argument has type C
if the bounds (in this case: an F-bound X extends A<X>
) are taken into account during constraint solution. In any case, the current behavior is that inference fails as mentioned, and this is a problem that does occur in practice (e.g., dart-lang/sdk#35799).
Metadata
Metadata
Assignees
Type
Projects
Status
Done