< prev index next >
src/jdk.compiler/share/classes/com/sun/tools/javac/parser/JavacParser.java
Print this page
*** 3178,3194 ****
JCTree elemType = TreeInfo.innermostType(type, true);
int startPos = Position.NOPOS;
if (elemType.hasTag(IDENT)) {
Name typeName = ((JCIdent)elemType).name;
if (isRestrictedLocalVarTypeName(typeName, pos, !compound && localDecl)) {
! if (compound) {
! //error - 'var' in compound local var decl
! reportSyntaxError(pos, Errors.VarNotAllowedCompound);
! } else if (type.hasTag(TYPEARRAY)) {
//error - 'var' and arrays
reportSyntaxError(pos, Errors.VarNotAllowedArray);
} else {
startPos = TreeInfo.getStartPos(mods);
if (startPos == Position.NOPOS)
startPos = TreeInfo.getStartPos(type);
//implicit type
type = null;
--- 3178,3194 ----
JCTree elemType = TreeInfo.innermostType(type, true);
int startPos = Position.NOPOS;
if (elemType.hasTag(IDENT)) {
Name typeName = ((JCIdent)elemType).name;
if (isRestrictedLocalVarTypeName(typeName, pos, !compound && localDecl)) {
! if (type.hasTag(TYPEARRAY) && !compound) {
//error - 'var' and arrays
reportSyntaxError(pos, Errors.VarNotAllowedArray);
} else {
+ if(compound)
+ //error - 'var' in compound local var decl
+ reportSyntaxError(pos, Errors.VarNotAllowedCompound);
startPos = TreeInfo.getStartPos(mods);
if (startPos == Position.NOPOS)
startPos = TreeInfo.getStartPos(type);
//implicit type
type = null;
< prev index next >