Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix a crash in expression switches #478

Merged
merged 1 commit into from
May 11, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -223,7 +223,7 @@ public Void visitCase(CaseTree node, Void unused) {
token(">");
builder.space();
scan(node.getBody(), null);
token(";");
builder.guessToken(";");
break;
default:
throw new AssertionError(node.getCaseKind());
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@
@RunWith(Parameterized.class)
public class FormatterIntegrationTest {

private static final ImmutableSet<String> JAVA14_TESTS = ImmutableSet.of("java14");
private static final ImmutableSet<String> JAVA14_TESTS = ImmutableSet.of("java14", "I477");

@Parameters(name = "{index}: {0}")
public static Iterable<Object[]> data() throws IOException {
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
class I477 {
public static String foo(int in) {
return switch (in) {
case 1 -> "A";
case 2 -> "B";
default -> throw new IllegalStateException("Unknown input " + in);
};
}

public static String foo(int in) {
return switch (in) {
case 1 -> "A";
case 2 -> "B";
default -> "C";
};
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
class I477 {
public static String foo(int in) {
return switch (in) {
case 1 -> "A";
case 2 -> "B";
default -> throw new IllegalStateException("Unknown input " + in);
};
}

public static String foo(int in) {
return switch (in) {
case 1 -> "A";
case 2 -> "B";
default -> "C";
};
}
}