It occurs to me if you have a A1 | A2 | A3 ...
where Ai <= A
and you call a method m
defined on A
but each Ai
may override with a more specific return type Ri
then you should get as a result R1 | R2 | R3 ...
This wouldn’t require any reflection since it is just propagating static information about the refined override return types.
Then, we can consider Int
as having 2^(32)
subtypes, and each have different values for def +[N <: Int](n: N): scala.compiletime.ops.int.+[this.type, N]
, but that could be done virtually at typechecking time.
Something like that…