Open jvasileff opened 7 years ago
Why is the intersection of Singleton<String>
and Singleton<Integer>
not simply Singleton<String&Integer>
and then evaluated to Singleton<Nothing>
?
And, are these calculations done at compile time on the JVM backend? Otherwise I have to replicate a lot of stuff in JS...
Why is the intersection of Singleton
and Singleton not simply Singleton<String&Integer> and then evaluated to Singleton ?
Great point @chochos. I think Nothing
is probably right because of the "nothing tuples", but the example would be more straight forward if it used class MySingleton<out Element>() {}
which I think would result in MySingleton<Nothing>
as you suggest.
For type literals I found out the calculation is done at compile time, so the type literalString&Integer
is eval'd as Nothing
at compile time, which is cool. But for inheritance it looks like it must be done at runtime, but I might be missing something...
Well at least now you get String&Integer
, or Singleton<String&Integer>
if you still use Singleton
.
OK now Singleton<String&Integer>
is resolved to Singleton<Nothing>
. Getting there.
Reified type arguments of interfaces that are satisfied multiple times do not properly account for the multiple satisfactions.
For example:
making
T
contravariant (interface I<in T> { ... }
) results in:rather than the expected:
interestingly, with a covariant
T
, but type args ofString
andInteger
(no longer boxed withSingleton
, the results are:vs. the ideal: