Skip to content

Commit

Permalink
Address comments
Browse files Browse the repository at this point in the history
  • Loading branch information
biboudis committed Mar 12, 2024
1 parent 25f6ffe commit f688c1e
Show file tree
Hide file tree
Showing 4 changed files with 21 additions and 5 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -2894,14 +2894,15 @@ List<JCStatement> blockStatement() {
int lookahead = 2;
int balance = 1;
boolean hasComma = false;
boolean hasTypeArgs = false;
boolean inTypeArgs = false;
Token l;
while ((l = S.token(lookahead)).kind != EOF && balance != 0) {
switch (l.kind) {
case LPAREN: balance++; break;
case RPAREN: balance--; break;
case COMMA: if (balance == 1 && !hasTypeArgs) hasComma = true; break;
case LT: hasTypeArgs = true;
case COMMA: if (balance == 1 && !inTypeArgs) hasComma = true; break;
case LT: inTypeArgs = true; break;
case GT: inTypeArgs = false;
}
lookahead++;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,11 +25,11 @@
* @test
* @bug 8326204
* @summary yield statements doesn't allow cast expressions with more than 1 type arguments
* @compile T8326204.java
* @compile T8326204a.java
*/
import java.util.*;

public class T8326204 {
public class T8326204a {
void testOneParam() {
Object value = new ArrayList<String>();
Object returnedValue = switch (1) {
Expand Down
13 changes: 13 additions & 0 deletions test/langtools/tools/javac/T8326204b.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
import java.util.Map;

/*
* @test /nodynamiccopyright/
* @bug 8326204
* @summary yield statements doesn't allow cast expressions with more than 1 type arguments
* @compile/fail/ref=T8326204b.out -XDrawDiagnostics --should-stop=at=FLOW -XDdev T8326204b.java
*/
public class T8326204b {
private static void t(int i) { yield((Map<String, String>) null, 2); }

private static void yield(Map<String, String> m, int j) { }
}
2 changes: 2 additions & 0 deletions test/langtools/tools/javac/T8326204b.out
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
T8326204b.java:10:36: compiler.err.invalid.yield
1 error

0 comments on commit f688c1e

Please sign in to comment.