Skip to content

Commit

Permalink
Test case for issue typetools#5412
Browse files Browse the repository at this point in the history
  • Loading branch information
mernst committed Dec 1, 2022
1 parent 9fbc8d2 commit c7238e6
Showing 1 changed file with 40 additions and 0 deletions.
40 changes: 40 additions & 0 deletions checker/tests/nullness/SwitchTestIssue5412.java
@@ -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";
};
}
}

0 comments on commit c7238e6

Please sign in to comment.