-
Notifications
You must be signed in to change notification settings - Fork 109
Open
Description
Using Eclipse
Version: 2025-12 (4.38.0)
Build id: 20251204-0850
With jdk 21 (altho targetting jdk17)
on Linux Mint 22
This class
package eclipsesaveactions;
import java.util.Arrays;
import java.util.Collections;
import java.util.List;
public class SaveActionsBug {
enum GiantSounds {Fee, Fi, Fo, Fum};
public List<String> convertToSwitchIssue(GiantSounds gs) {
String key;
switch (gs) {
case Fee:
key = "Oh My";
break;
case Fi:
key = "Wow";
break;
case Fo:
key = "Uh oh";
break;
default: return Collections.emptyList();
}
return Arrays.asList("Yikes", key);
}
}
When convert to switch expressions is turned on and you auto save converts to
package eclipsesaveactions;
import java.util.Arrays;
import java.util.Collections;
import java.util.List;
public class SaveActionsBug {
enum GiantSounds {
Fee,
Fi,
Fo,
Fum
}
public List<String> convertToSwitchIssue(GiantSounds gs) {
String key;
key = switch (gs) {
case Fee -> key = "Oh My";
case Fi -> key = "Wow";
case Fo -> key = "Uh oh";
default -> {
return Collections.emptyList();
}
};
return Arrays.asList("Yikes", key);
}
}
which is incorrect.
Metadata
Metadata
Assignees
Labels
No labels