3037 //where |
3037 //where |
3038 JCVariableDecl variableDeclaratorId(JCModifiers mods, JCExpression type, boolean lambdaParameter) { |
3038 JCVariableDecl variableDeclaratorId(JCModifiers mods, JCExpression type, boolean lambdaParameter) { |
3039 int pos = token.pos; |
3039 int pos = token.pos; |
3040 Name name; |
3040 Name name; |
3041 if (lambdaParameter && token.kind == UNDERSCORE) { |
3041 if (lambdaParameter && token.kind == UNDERSCORE) { |
3042 log.error(pos, "underscore.as.identifier.in.lambda"); |
3042 log.error(pos, Errors.UnderscoreAsIdentifierInLambda); |
3043 name = token.name(); |
3043 name = token.name(); |
3044 nextToken(); |
3044 nextToken(); |
3045 } else { |
3045 } else { |
3046 if (allowThisIdent && !lambdaParameter) { |
3046 if (allowThisIdent && !lambdaParameter) { |
3047 JCExpression pn = qualident(false); |
3047 JCExpression pn = qualident(false); |
3048 if (pn.hasTag(Tag.IDENT) && ((JCIdent)pn).name != names._this) { |
3048 if (pn.hasTag(Tag.IDENT) && ((JCIdent)pn).name != names._this) { |
3049 name = ((JCIdent)pn).name; |
3049 name = ((JCIdent)pn).name; |
3050 } else { |
3050 } else { |
3051 if ((mods.flags & Flags.VARARGS) != 0) { |
3051 if ((mods.flags & Flags.VARARGS) != 0) { |
3052 log.error(token.pos, "varargs.and.receiver"); |
3052 log.error(token.pos, Errors.VarargsAndReceiver); |
3053 } |
3053 } |
3054 if (token.kind == LBRACKET) { |
3054 if (token.kind == LBRACKET) { |
3055 log.error(token.pos, "array.and.receiver"); |
3055 log.error(token.pos, Errors.ArrayAndReceiver); |
3056 } |
3056 } |
3057 return toP(F.at(pos).ReceiverVarDef(mods, pn, type)); |
3057 return toP(F.at(pos).ReceiverVarDef(mods, pn, type)); |
3058 } |
3058 } |
3059 } else { |
3059 } else { |
3060 name = ident(); |
3060 name = ident(); |
3061 } |
3061 } |
3062 } |
3062 } |
3063 if ((mods.flags & Flags.VARARGS) != 0 && |
3063 if ((mods.flags & Flags.VARARGS) != 0 && |
3064 token.kind == LBRACKET) { |
3064 token.kind == LBRACKET) { |
3065 log.error(token.pos, "varargs.and.old.array.syntax"); |
3065 log.error(token.pos, Errors.VarargsAndOldArraySyntax); |
3066 } |
3066 } |
3067 type = bracketsOpt(type); |
3067 type = bracketsOpt(type); |
3068 return toP(F.at(pos).VarDef(mods, name, type, null)); |
3068 return toP(F.at(pos).VarDef(mods, name, type, null)); |
3069 } |
3069 } |
3070 |
3070 |
4142 } |
4142 } |
4143 } |
4143 } |
4144 |
4144 |
4145 void checkDiamond() { |
4145 void checkDiamond() { |
4146 if (!allowDiamond) { |
4146 if (!allowDiamond) { |
4147 log.error(DiagnosticFlag.SOURCE_LEVEL, token.pos, "diamond.not.supported.in.source", source.name); |
4147 log.error(DiagnosticFlag.SOURCE_LEVEL, token.pos, Errors.DiamondNotSupportedInSource(source.name)); |
4148 } |
4148 } |
4149 } |
4149 } |
4150 void checkMulticatch() { |
4150 void checkMulticatch() { |
4151 if (!allowMulticatch) { |
4151 if (!allowMulticatch) { |
4152 log.error(DiagnosticFlag.SOURCE_LEVEL, token.pos, "multicatch.not.supported.in.source", source.name); |
4152 log.error(DiagnosticFlag.SOURCE_LEVEL, token.pos, Errors.MulticatchNotSupportedInSource(source.name)); |
4153 } |
4153 } |
4154 } |
4154 } |
4155 void checkTryWithResources() { |
4155 void checkTryWithResources() { |
4156 if (!allowTWR) { |
4156 if (!allowTWR) { |
4157 log.error(DiagnosticFlag.SOURCE_LEVEL, token.pos, "try.with.resources.not.supported.in.source", source.name); |
4157 log.error(DiagnosticFlag.SOURCE_LEVEL, token.pos, Errors.TryWithResourcesNotSupportedInSource(source.name)); |
4158 } |
4158 } |
4159 } |
4159 } |
4160 void checkVariableInTryWithResources(int startPos) { |
4160 void checkVariableInTryWithResources(int startPos) { |
4161 if (!allowEffectivelyFinalVariablesInTWR) { |
4161 if (!allowEffectivelyFinalVariablesInTWR) { |
4162 log.error(DiagnosticFlag.SOURCE_LEVEL, startPos, "var.in.try.with.resources.not.supported.in.source", source.name); |
4162 log.error(DiagnosticFlag.SOURCE_LEVEL, startPos, Errors.VarInTryWithResourcesNotSupportedInSource(source.name)); |
4163 } |
4163 } |
4164 } |
4164 } |
4165 void checkLambda() { |
4165 void checkLambda() { |
4166 if (!allowLambda) { |
4166 if (!allowLambda) { |
4167 log.error(DiagnosticFlag.SOURCE_LEVEL, token.pos, "lambda.not.supported.in.source", source.name); |
4167 log.error(DiagnosticFlag.SOURCE_LEVEL, token.pos, Errors.LambdaNotSupportedInSource(source.name)); |
4168 } |
4168 } |
4169 } |
4169 } |
4170 void checkMethodReferences() { |
4170 void checkMethodReferences() { |
4171 if (!allowMethodReferences) { |
4171 if (!allowMethodReferences) { |
4172 log.error(DiagnosticFlag.SOURCE_LEVEL, token.pos, "method.references.not.supported.in.source", source.name); |
4172 log.error(DiagnosticFlag.SOURCE_LEVEL, token.pos, Errors.MethodReferencesNotSupportedInSource(source.name)); |
4173 } |
4173 } |
4174 } |
4174 } |
4175 void checkDefaultMethods() { |
4175 void checkDefaultMethods() { |
4176 if (!allowDefaultMethods) { |
4176 if (!allowDefaultMethods) { |
4177 log.error(DiagnosticFlag.SOURCE_LEVEL, token.pos, "default.methods.not.supported.in.source", source.name); |
4177 log.error(DiagnosticFlag.SOURCE_LEVEL, token.pos, Errors.DefaultMethodsNotSupportedInSource(source.name)); |
4178 } |
4178 } |
4179 } |
4179 } |
4180 void checkIntersectionTypesInCast() { |
4180 void checkIntersectionTypesInCast() { |
4181 if (!allowIntersectionTypesInCast) { |
4181 if (!allowIntersectionTypesInCast) { |
4182 log.error(DiagnosticFlag.SOURCE_LEVEL, token.pos, "intersection.types.in.cast.not.supported.in.source", source.name); |
4182 log.error(DiagnosticFlag.SOURCE_LEVEL, token.pos, Errors.IntersectionTypesInCastNotSupportedInSource(source.name)); |
4183 } |
4183 } |
4184 } |
4184 } |
4185 void checkStaticInterfaceMethods() { |
4185 void checkStaticInterfaceMethods() { |
4186 if (!allowStaticInterfaceMethods) { |
4186 if (!allowStaticInterfaceMethods) { |
4187 log.error(DiagnosticFlag.SOURCE_LEVEL, token.pos, "static.intf.methods.not.supported.in.source", source.name); |
4187 log.error(DiagnosticFlag.SOURCE_LEVEL, token.pos, Errors.StaticIntfMethodsNotSupportedInSource(source.name)); |
4188 } |
4188 } |
4189 } |
4189 } |
4190 void checkTypeAnnotations() { |
4190 void checkTypeAnnotations() { |
4191 if (!allowTypeAnnotations) { |
4191 if (!allowTypeAnnotations) { |
4192 log.error(DiagnosticFlag.SOURCE_LEVEL, token.pos, "type.annotations.not.supported.in.source", source.name); |
4192 log.error(DiagnosticFlag.SOURCE_LEVEL, token.pos, Errors.TypeAnnotationsNotSupportedInSource(source.name)); |
4193 } |
4193 } |
4194 } |
4194 } |
4195 void checkPrivateInterfaceMethods() { |
4195 void checkPrivateInterfaceMethods() { |
4196 if (!allowPrivateInterfaceMethods) { |
4196 if (!allowPrivateInterfaceMethods) { |
4197 log.error(DiagnosticFlag.SOURCE_LEVEL, token.pos, CompilerProperties.Errors.PrivateIntfMethodsNotSupportedInSource(source.name)); |
4197 log.error(DiagnosticFlag.SOURCE_LEVEL, token.pos, CompilerProperties.Errors.PrivateIntfMethodsNotSupportedInSource(source.name)); |
4198 } |
4198 } |
4199 } |
4199 } |
4200 protected void checkAnnotationsAfterTypeParams(int pos) { |
4200 protected void checkAnnotationsAfterTypeParams(int pos) { |
4201 if (!allowAnnotationsAfterTypeParams) { |
4201 if (!allowAnnotationsAfterTypeParams) { |
4202 log.error(DiagnosticFlag.SOURCE_LEVEL, pos, "annotations.after.type.params.not.supported.in.source", source.name); |
4202 log.error(DiagnosticFlag.SOURCE_LEVEL, pos, Errors.AnnotationsAfterTypeParamsNotSupportedInSource(source.name)); |
4203 } |
4203 } |
4204 } |
4204 } |
4205 |
4205 |
4206 /* |
4206 /* |
4207 * a functional source tree and end position mappings |
4207 * a functional source tree and end position mappings |