Tagged Unions in valhalla
Ben
benharless820 at gmail.com
Thu Nov 13 18:27:04 UTC 2025
Hello,
I've been looking for information on how tagged unions will pan out in
valhalla.
A tagged union in java would be something like
```
public sealed abstract value class Shape permits Circle, Square {}
public value class Circle extends Shape {
public float radius;
}
public value class Square extends Shape {
public float side;
}
```
(adapted from
https://docs.oracle.com/en/java/javase/17/language/sealed-classes-and-interfaces.html
)
>From what I know currently, this wouldn't end up being scalarized or
flattened, even though the JVM runtime knows that only Circle and Square
can extend Shape.
Is there a future where these do end up getting flattened or scalarized?
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://mail.openjdk.org/pipermail/valhalla-spec-observers/attachments/20251113/47b6db98/attachment.htm>
More information about the valhalla-spec-observers
mailing list