< prev index next >

src/jdk.compiler/share/classes/com/sun/tools/javac/comp/TypeEnter.java

Print this page

 903             }
 904             if (sym.owner.kind == PCK && (sym.flags_field & PUBLIC) == 0 &&
 905                 !env.toplevel.sourcefile.isNameCompatible(sym.name.toString(),JavaFileObject.Kind.SOURCE)) {
 906                 sym.flags_field |= AUXILIARY;
 907             }
 908         }
 909 
 910         private void fillPermits(JCClassDecl tree, Env<AttrContext> baseEnv) {
 911             ClassSymbol sym = tree.sym;
 912 
 913             //fill in implicit permits in supertypes:
 914             if (!sym.isAnonymous() || sym.isEnum()) {
 915                 for (Type supertype : types.directSupertypes(sym.type)) {
 916                     if (supertype.tsym.kind == TYP) {
 917                         ClassSymbol supClass = (ClassSymbol) supertype.tsym;
 918                         Env<AttrContext> supClassEnv = enter.getEnv(supClass);
 919                         if (supClass.isSealed() &&
 920                             !supClass.isPermittedExplicit &&
 921                             supClassEnv != null &&
 922                             supClassEnv.toplevel == baseEnv.toplevel) {
 923                             supClass.permitted = supClass.permitted.append(sym);
 924                         }
 925                     }
 926                 }
 927             }
 928             // attribute (explicit) permits of the current class:
 929             if (sym.isPermittedExplicit) {
 930                 ListBuffer<Symbol> permittedSubtypeSymbols = new ListBuffer<>();
 931                 List<JCExpression> permittedTrees = tree.permitting;
 932                 for (JCExpression permitted : permittedTrees) {
 933                     Type pt = attr.attribBase(permitted, baseEnv, false, false, false);
 934                     permittedSubtypeSymbols.append(pt.tsym);
 935                 }
 936                 sym.permitted = permittedSubtypeSymbols.toList();
 937             }
 938         }
 939     }
 940 
 941     private abstract class AbstractMembersPhase extends Phase {
 942 
 943         public AbstractMembersPhase(CompletionCause completionCause, Phase next) {
 944             super(completionCause, next);
 945         }
 946 
 947         private boolean completing;
 948         private List<Env<AttrContext>> todo = List.nil();
 949 
 950         @Override
 951         protected void doCompleteEnvs(List<Env<AttrContext>> envs) {
 952             todo = todo.prependList(envs);
 953             if (completing) {
 954                 return ; //the top-level invocation will handle all envs
 955             }
 956             boolean prevCompleting = completing;

 903             }
 904             if (sym.owner.kind == PCK && (sym.flags_field & PUBLIC) == 0 &&
 905                 !env.toplevel.sourcefile.isNameCompatible(sym.name.toString(),JavaFileObject.Kind.SOURCE)) {
 906                 sym.flags_field |= AUXILIARY;
 907             }
 908         }
 909 
 910         private void fillPermits(JCClassDecl tree, Env<AttrContext> baseEnv) {
 911             ClassSymbol sym = tree.sym;
 912 
 913             //fill in implicit permits in supertypes:
 914             if (!sym.isAnonymous() || sym.isEnum()) {
 915                 for (Type supertype : types.directSupertypes(sym.type)) {
 916                     if (supertype.tsym.kind == TYP) {
 917                         ClassSymbol supClass = (ClassSymbol) supertype.tsym;
 918                         Env<AttrContext> supClassEnv = enter.getEnv(supClass);
 919                         if (supClass.isSealed() &&
 920                             !supClass.isPermittedExplicit &&
 921                             supClassEnv != null &&
 922                             supClassEnv.toplevel == baseEnv.toplevel) {
 923                             supClass.addPermittedSubclass(sym, tree.pos);
 924                         }
 925                     }
 926                 }
 927             }
 928             // attribute (explicit) permits of the current class:
 929             if (sym.isPermittedExplicit) {
 930                 ListBuffer<Symbol> permittedSubtypeSymbols = new ListBuffer<>();
 931                 List<JCExpression> permittedTrees = tree.permitting;
 932                 for (JCExpression permitted : permittedTrees) {
 933                     Type pt = attr.attribBase(permitted, baseEnv, false, false, false);
 934                     permittedSubtypeSymbols.append(pt.tsym);
 935                 }
 936                 sym.setPermittedSubclasses(permittedSubtypeSymbols.toList());
 937             }
 938         }
 939     }
 940 
 941     private abstract class AbstractMembersPhase extends Phase {
 942 
 943         public AbstractMembersPhase(CompletionCause completionCause, Phase next) {
 944             super(completionCause, next);
 945         }
 946 
 947         private boolean completing;
 948         private List<Env<AttrContext>> todo = List.nil();
 949 
 950         @Override
 951         protected void doCompleteEnvs(List<Env<AttrContext>> envs) {
 952             todo = todo.prependList(envs);
 953             if (completing) {
 954                 return ; //the top-level invocation will handle all envs
 955             }
 956             boolean prevCompleting = completing;
< prev index next >