644 new VarSymbol(0, tree.name, tree.vartype.type, enclScope.owner); |
644 new VarSymbol(0, tree.name, tree.vartype.type, enclScope.owner); |
645 v.flags_field = chk.checkFlags(tree.pos(), tree.mods.flags, v, tree); |
645 v.flags_field = chk.checkFlags(tree.pos(), tree.mods.flags, v, tree); |
646 tree.sym = v; |
646 tree.sym = v; |
647 if (tree.init != null) { |
647 if (tree.init != null) { |
648 v.flags_field |= HASINIT; |
648 v.flags_field |= HASINIT; |
649 if ((v.flags_field & FINAL) != 0 && !tree.init.hasTag(NEWCLASS)) { |
649 if ((v.flags_field & FINAL) != 0 && |
|
650 !tree.init.hasTag(NEWCLASS) && |
|
651 !tree.init.hasTag(LAMBDA)) { |
650 Env<AttrContext> initEnv = getInitEnv(tree, env); |
652 Env<AttrContext> initEnv = getInitEnv(tree, env); |
651 initEnv.info.enclVar = v; |
653 initEnv.info.enclVar = v; |
652 v.setLazyConstValue(initEnv(tree, initEnv), attr, tree.init); |
654 v.setLazyConstValue(initEnv(tree, initEnv), attr, tree.init); |
653 } |
655 } |
654 } |
656 } |
669 * @param env The environment current outside of the variable definition. |
671 * @param env The environment current outside of the variable definition. |
670 */ |
672 */ |
671 Env<AttrContext> initEnv(JCVariableDecl tree, Env<AttrContext> env) { |
673 Env<AttrContext> initEnv(JCVariableDecl tree, Env<AttrContext> env) { |
672 Env<AttrContext> localEnv = env.dupto(new AttrContextEnv(tree, env.info.dup())); |
674 Env<AttrContext> localEnv = env.dupto(new AttrContextEnv(tree, env.info.dup())); |
673 if (tree.sym.owner.kind == TYP) { |
675 if (tree.sym.owner.kind == TYP) { |
674 localEnv.info.scope = new Scope.DelegatedScope(env.info.scope); |
676 localEnv.info.scope = env.info.scope.dupUnshared(); |
675 localEnv.info.scope.owner = tree.sym; |
677 localEnv.info.scope.owner = tree.sym; |
676 } |
678 } |
677 if ((tree.mods.flags & STATIC) != 0 || |
679 if ((tree.mods.flags & STATIC) != 0 || |
678 (env.enclClass.sym.flags() & INTERFACE) != 0) |
680 (env.enclClass.sym.flags() & INTERFACE) != 0) |
679 localEnv.info.staticLevel++; |
681 localEnv.info.staticLevel++; |