Skip to content
This repository has been archived by the owner. It is now read-only.
Permalink
Browse files
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
  • Loading branch information
Jan Lahoda committed Mar 16, 2020
1 parent 95898e8 commit 6ddb0f2b2cf27530bb1b2f15c98c5ed61816b8f1
Showing with 17 additions and 2 deletions.
  1. +1 −1 src/jdk.compiler/share/classes/com/sun/tools/javac/parser/JavacParser.java
  2. +16 −1 test/langtools/tools/javac/switchexpr/ExpressionSwitch.java
@@ -2582,7 +2582,7 @@ List<JCStatement> blockStatement() {
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 @@ private int convert2(String s) {
};
}

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 {

0 comments on commit 6ddb0f2

Please sign in to comment.