--- a/src/jdk.compiler/share/classes/com/sun/tools/javac/parser/JavacParser.java Fri May 24 04:18:18 2019 -0700
+++ b/src/jdk.compiler/share/classes/com/sun/tools/javac/parser/JavacParser.java Tue Jul 02 09:14:51 2019 +0200
@@ -775,9 +775,9 @@
public JCExpression unannotatedType(boolean allowVar) {
JCExpression result = term(TYPE);
- Name restrictedTypeName;
-
- if (!allowVar && (restrictedTypeName = restrictedTypeName(result, true)) != null) {
+ Name restrictedTypeName = restrictedTypeName(result, !allowVar);
+
+ if (restrictedTypeName != null && (!allowVar || restrictedTypeName != names.var)) {
syntaxError(result.pos, Errors.RestrictedTypeNotAllowedHere(restrictedTypeName));
}