eclipse-jdt / eclipse.jdt.core

Eclipse Public License 2.0
157 stars 125 forks source link

Issue #2928 unexpected operand error with case double #2930

Closed mpalat closed 1 week ago

mpalat commented 1 week ago

fixes issue #2928

What it does

How to test

Author checklist

stephan-herrmann commented 1 week ago

@mpalat for posterity it would be good to have a little explanation while your memory is still fresh.

When I saw the stacktrace in #2928 my first thought was: someone tried to pop an int from the stack when in fact a double was at the top. Your fix seems to indicate that code gen actually had a different bug. What wrong did code gen do prior to your change?

The code you added in needPatternDispatchCopy() tests the flag isPrimitiveSwitch. Do you assume that we can enter this code (part of code gen) with isPrimitiveSwitch being false? If yes, then what should code gen do as an else to the new if? If no, then why do we need this if? Looking from a distance I think, the combination (switch over double and !isPrimitiveSwitch) will have raised an error during resolve, implying that code gen will never be performed for that method. If that is correct, then promoting isPrimitiveSwitch from local to field would be unnecessary.