4205 }
4206 break;
4207 case METHODDEF:
4208 case CLASSDEF:
4209 case TOPLEVEL:
4210 return null;
4211 }
4212 Assert.checkNonNull(env.next);
4213 env = env.next;
4214 }
4215 }
4216
4217 /**
4218 * Check for illegal references to static members of enum. In
4219 * an enum type, constructors and initializers may not
4220 * reference its static members unless they are constant.
4221 *
4222 * @param tree The tree making up the variable reference.
4223 * @param env The current environment.
4224 * @param v The variable's symbol.
4225 * @jls section 8.9 Enums
4226 */
4227 private void checkEnumInitializer(JCTree tree, Env<AttrContext> env, VarSymbol v) {
4228 // JLS:
4229 //
4230 // "It is a compile-time error to reference a static field
4231 // of an enum type that is not a compile-time constant
4232 // (15.28) from constructors, instance initializer blocks,
4233 // or instance variable initializer expressions of that
4234 // type. It is a compile-time error for the constructors,
4235 // instance initializer blocks, or instance variable
4236 // initializer expressions of an enum constant e to refer
4237 // to itself or to an enum constant of the same type that
4238 // is declared to the right of e."
4239 if (isStaticEnumField(v)) {
4240 ClassSymbol enclClass = env.info.scope.owner.enclClass();
4241
4242 if (enclClass == null || enclClass.owner == null)
4243 return;
4244
4245 // See if the enclosing class is the enum (or a
|
4205 }
4206 break;
4207 case METHODDEF:
4208 case CLASSDEF:
4209 case TOPLEVEL:
4210 return null;
4211 }
4212 Assert.checkNonNull(env.next);
4213 env = env.next;
4214 }
4215 }
4216
4217 /**
4218 * Check for illegal references to static members of enum. In
4219 * an enum type, constructors and initializers may not
4220 * reference its static members unless they are constant.
4221 *
4222 * @param tree The tree making up the variable reference.
4223 * @param env The current environment.
4224 * @param v The variable's symbol.
4225 * @jls 8.9 Enum Types
4226 */
4227 private void checkEnumInitializer(JCTree tree, Env<AttrContext> env, VarSymbol v) {
4228 // JLS:
4229 //
4230 // "It is a compile-time error to reference a static field
4231 // of an enum type that is not a compile-time constant
4232 // (15.28) from constructors, instance initializer blocks,
4233 // or instance variable initializer expressions of that
4234 // type. It is a compile-time error for the constructors,
4235 // instance initializer blocks, or instance variable
4236 // initializer expressions of an enum constant e to refer
4237 // to itself or to an enum constant of the same type that
4238 // is declared to the right of e."
4239 if (isStaticEnumField(v)) {
4240 ClassSymbol enclClass = env.info.scope.owner.enclClass();
4241
4242 if (enclClass == null || enclClass.owner == null)
4243 return;
4244
4245 // See if the enclosing class is the enum (or a
|