8240964: Compilation error thrown when long literal used with yield
Ensuring yield followed by a long literal is recognized as a yield statement. Reviewed-by: mcimadamore
This commit is contained in:
parent
95898e86a1
commit
6ddb0f2b2c
src/jdk.compiler/share/classes/com/sun/tools/javac/parser
test/langtools/tools/javac/switchexpr
@ -2582,7 +2582,7 @@ public class JavacParser implements Parser {
|
||||
boolean isYieldStatement;
|
||||
switch (next.kind) {
|
||||
case PLUS: case SUB: case STRINGLITERAL: case CHARLITERAL:
|
||||
case INTLITERAL: case FLOATLITERAL: case DOUBLELITERAL:
|
||||
case INTLITERAL: case LONGLITERAL: case FLOATLITERAL: case DOUBLELITERAL:
|
||||
case NULL: case IDENTIFIER: case TRUE: case FALSE:
|
||||
case NEW: case SWITCH: case THIS: case SUPER:
|
||||
isYieldStatement = true;
|
||||
|
@ -1,6 +1,6 @@
|
||||
/*
|
||||
* @test /nodynamiccopyright/
|
||||
* @bug 8206986 8222169 8224031
|
||||
* @bug 8206986 8222169 8224031 8240964
|
||||
* @summary Check expression switch works.
|
||||
* @compile/fail/ref=ExpressionSwitch-old.out -source 9 -Xlint:-options -XDrawDiagnostics ExpressionSwitch.java
|
||||
* @compile ExpressionSwitch.java
|
||||
@ -104,6 +104,21 @@ public class ExpressionSwitch {
|
||||
};
|
||||
}
|
||||
|
||||
private Object yieldDisambiguationLiterals(String s) {
|
||||
return switch (s) {
|
||||
case "a": yield 0;
|
||||
case "b": yield 0L;
|
||||
case "c": yield 0.0f;
|
||||
case "d": yield 0.0d;
|
||||
case "e": yield true;
|
||||
case "f": yield false;
|
||||
case "g": yield '0';
|
||||
case "h": yield "";
|
||||
case "i": yield null;
|
||||
default: yield 0;
|
||||
};
|
||||
}
|
||||
|
||||
private void localClass(T t) {
|
||||
String good = "good";
|
||||
class L {
|
||||
|
Loading…
x
Reference in New Issue
Block a user