8185983: Javac should reject TypeArguments on field access expression

Reviewed-by: mcimadamore
This commit is contained in:
Vicente Romero 2017-11-27 10:40:42 -05:00
parent 589129ece4
commit 18f70cfdd2
3 changed files with 17 additions and 0 deletions

View File

@ -1319,6 +1319,9 @@ public class JavacParser implements Parser {
break loop; break loop;
case DOT: case DOT:
nextToken(); nextToken();
if (token.kind == TokenKind.IDENTIFIER && typeArgs != null) {
return illegal();
}
int oldmode = mode; int oldmode = mode;
mode &= ~NOPARAMS; mode &= ~NOPARAMS;
typeArgs = typeArgumentsOpt(EXPR); typeArgs = typeArgumentsOpt(EXPR);

View File

@ -0,0 +1,12 @@
/*
* @test /nodynamiccopyright/
* @bug 8185983
* @summary Javac should reject TypeArguments on field access expression
* @compile/fail/ref=RejectTypeArgsOnSelectTest.out -XDrawDiagnostics RejectTypeArgsOnSelectTest.java
*/
import java.util.*;
class RejectTypeArgsOnSelectTest {
Iterator<RejectTypeArgsOnSelectTest> nullIter = Collections.<RejectTypeArgsOnSelectTest>EMPTY_LIST.iterator();
}

View File

@ -0,0 +1,2 @@
RejectTypeArgsOnSelectTest.java:11:104: compiler.err.illegal.start.of.expr
1 error