Intersection and Union Types for Java
Suminda Sirinath Salpitikorala Dharmasena
sirinath1978m at gmail.com
Wed Jan 20 06:53:11 UTC 2021
Hello,
Can the Java type system be extended to accommodate Intersection and Union
Types.
Currently we can write:
<T extends A & B> void f(T t) { ... }
but not
<T extends A | B> void f(T t) { ... }
or
<T extends (A | B) & C> void f(T t) { ... }
Also we cannot have
void f(A & B t) { ... }
or
void f((A | B) & C t) { ... }
When considering languages like Ceylon (https://ceylon-lang.org/) and Scala
3 / Dotty (https://dotty.epfl.ch/) these seem to be very useful.
Suminda
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://mail.openjdk.java.net/pipermail/compiler-dev/attachments/20210120/18b621f0/attachment.htm>
More information about the compiler-dev
mailing list