8185983: Javac should reject TypeArguments on field access expression
authorvromero
Mon, 27 Nov 2017 10:40:42 -0500
changeset 47936 3b1ef48862cf
parent 47935 cd2764b618b9
child 47937 c1437939b0d8
8185983: Javac should reject TypeArguments on field access expression Reviewed-by: mcimadamore
src/jdk.compiler/share/classes/com/sun/tools/javac/parser/JavacParser.java
test/langtools/tools/javac/T8185983/RejectTypeArgsOnSelectTest.java
test/langtools/tools/javac/T8185983/RejectTypeArgsOnSelectTest.out
--- a/src/jdk.compiler/share/classes/com/sun/tools/javac/parser/JavacParser.java	Mon Nov 27 17:04:33 2017 +0530
+++ b/src/jdk.compiler/share/classes/com/sun/tools/javac/parser/JavacParser.java	Mon Nov 27 10:40:42 2017 -0500
@@ -1319,6 +1319,9 @@
                         break loop;
                     case DOT:
                         nextToken();
+                        if (token.kind == TokenKind.IDENTIFIER && typeArgs != null) {
+                            return illegal();
+                        }
                         int oldmode = mode;
                         mode &= ~NOPARAMS;
                         typeArgs = typeArgumentsOpt(EXPR);
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/test/langtools/tools/javac/T8185983/RejectTypeArgsOnSelectTest.java	Mon Nov 27 10:40:42 2017 -0500
@@ -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();
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/test/langtools/tools/javac/T8185983/RejectTypeArgsOnSelectTest.out	Mon Nov 27 10:40:42 2017 -0500
@@ -0,0 +1,2 @@
+RejectTypeArgsOnSelectTest.java:11:104: compiler.err.illegal.start.of.expr
+1 error