-
Notifications
You must be signed in to change notification settings - Fork 861
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
`throws` statements are allows to occur in non-block expression switch cases, which was causing the trailing `;` to be printed twice. Fixes #477 PiperOrigin-RevId: 310735686
- Loading branch information
Showing
4 changed files
with
36 additions
and
2 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
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
17 changes: 17 additions & 0 deletions
17
core/src/test/resources/com/google/googlejavaformat/java/testdata/I477.input
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,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"; | ||
}; | ||
} | ||
} |
17 changes: 17 additions & 0 deletions
17
core/src/test/resources/com/google/googlejavaformat/java/testdata/I477.output
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,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"; | ||
}; | ||
} | ||
} |