Closed jvasileff closed 5 years ago
Oh, wait, I see, this I<String>
is a pretty nonsensical type. At least, it's unpopulated.
Fixed, thanks.
Oh, wait, I see, this I
is a pretty nonsensical type. At least, it's unpopulated.
Ah, yeah, bad example since String
is final. There's also:
interface J {}
interface I<T> of T {}
void run(I<J> s) {
I<out Anything> s1 = s; // ok
I<in Nothing> s2 = s; // ok
value s11 = s of I<out Anything>; // error 1
value s22 = s of I<in Nothing>; // error 2
}
The patch allows:
interface J {}
interface I<T> of T {}
class C() satisfies J & I<J> {}
class D() {}
shared void run() {
I<J> c = C();
D s = c of D; // error: java.lang.ClassCastException: simple.C cannot be cast to simple.D
}
(Or more directly, the expression (C() of I<J>) of Nothing
)
@jvasileff nice catch. But v2 of the patch, which I was already in the works when you posted, seems to have fixed that problem too. But anyway I'll add it as a test.
I would say this is fixed now.
The expression
v of Supertype
fails below: