Type primitive pattern: the problem with primitive and boxing
Remi Forax
forax at univ-mlv.fr
Thu Sep 11 14:52:37 UTC 2025
Following Brian and Dan comments, I restart several different threads.
The way JEP 507 semantics is defined does not work well with the idea that int can be seen as a subtype of Integer, or at least seen int and Integer! as interoperable.
For example, this code compile
int v = ...
switch(v) {
case byte b -> ...
case int i -> ...
}
But this code does not compile
Integer v = ...
switch(v) {
case byte b -> ...
case int i -> ...
}
so at best there is a risk of making our lives (the Valhalla EG) miserable in the future because of the semantics of this JEP, at worst, in the future, people will declare the component of their records either as an Integer! or as an int to get the flavor of pattern matching they want.
regards,
Rémi
More information about the amber-spec-observers
mailing list