On Wed, 5 Nov 2025 15:05:09 GMT, Jan Lahoda <[email protected]> wrote:
>> We can combined the labels, but since we're setting _two_ values we can't
>> use the `->` syntax. Fixed in 8044632727d.
>
> Having two assignments should not be a blocker for `->`, no? It ought to be
> enough to use `{}`:
>
> switch (((OperatorSymbol)operator).opcode) {
> case ByteCodes.ishl, ByteCodes.ishr, ByteCodes.iushr,
> ByteCodes.ishll, ByteCodes.ishrl, ByteCodes.iushrl -> {
> targetType = syms.intType;
> maximumShift = 32;
> }
> case ByteCodes.lshl, ByteCodes.lshr, ByteCodes.lushr,
> ByteCodes.lshll, ByteCodes.lshrl, ByteCodes.lushrl -> {
> targetType = syms.longType;
> maximumShift = 64;
> }
> default -> {
> return;
> }
> }
>
>
> I am not strictly insisting on using `->`, but it generally makes things
> simpler as there's guaranteed no fallthrough.
The `->` can be used, even when having general statements/multiple
assignments/etc. - just wrap the code with `{}`, no?
switch (((OperatorSymbol)operator).opcode) {
case ByteCodes.ishl, ByteCodes.ishr, ByteCodes.iushr,
ByteCodes.ishll, ByteCodes.ishrl, ByteCodes.iushrl -> {
targetType = syms.intType;
maximumShift = 32;
}
case ByteCodes.lshl, ByteCodes.lshr, ByteCodes.lushr,
ByteCodes.lshll, ByteCodes.lshrl, ByteCodes.lushrl -> {
targetType = syms.longType;
maximumShift = 64;
}
default -> {
return;
}
}
I am not strictly insisting on using `->` but it is typically easier to reason
about switches that are guaranteed to not have fallthrough.
-------------
PR Review Comment: https://git.openjdk.org/jdk/pull/27102#discussion_r2495005451