forked from typetools/checker-framework
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
1 changed file
with
40 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,40 @@ | ||
// Test case for https://github.com/typetools/checker-framework/issues/5412 | ||
|
||
// @below-java17-jdk-skip-test | ||
|
||
enum MyEnum { | ||
VAL1, | ||
VAL2, | ||
VAL3 | ||
} | ||
|
||
class SwitchTestExhaustive { | ||
public String foo1(MyEnum b) { | ||
final var s = | ||
switch (b) { | ||
case VAL1 -> "1"; | ||
case VAL2 -> "2"; | ||
case VAL3 -> "3"; | ||
}; | ||
return s; | ||
} | ||
|
||
public String foo2(MyEnum b) { | ||
final var s = | ||
switch (b) { | ||
case VAL1 -> "1"; | ||
case VAL2 -> "2"; | ||
case VAL3 -> "3"; | ||
default -> throw new RuntimeException(); | ||
}; | ||
return s; | ||
} | ||
|
||
public String foo3(MyEnum b) { | ||
return switch (b) { | ||
case VAL1 -> "1"; | ||
case VAL2 -> "2"; | ||
case VAL3 -> "3"; | ||
}; | ||
} | ||
} |