langtools/src/jdk.compiler/share/classes/com/sun/tools/javac/comp/Attr.java
changeset 44571 1140b8dad6bb
parent 44393 ce94820fa9d1
child 45504 ea7475564d07
equal deleted inserted replaced
44570:7fec4e13a5cf 44571:1140b8dad6bb
   503             this.pt = pt;
   503             this.pt = pt;
   504             this.checkContext = checkContext;
   504             this.checkContext = checkContext;
   505             this.checkMode = checkMode;
   505             this.checkMode = checkMode;
   506         }
   506         }
   507 
   507 
   508         protected void attr(JCTree tree, Env<AttrContext> env) {
   508         /**
   509             tree.accept(Attr.this);
   509          * Should {@link Attr#attribTree} use the {@ArgumentAttr} visitor instead of this one?
   510         }
   510          * @param tree The tree to be type-checked.
       
   511          * @return true if {@ArgumentAttr} should be used.
       
   512          */
       
   513         protected boolean needsArgumentAttr(JCTree tree) { return false; }
   511 
   514 
   512         protected Type check(final DiagnosticPosition pos, final Type found) {
   515         protected Type check(final DiagnosticPosition pos, final Type found) {
   513             return chk.checkType(pos, found, pt, checkContext);
   516             return chk.checkType(pos, found, pt, checkContext);
   514         }
   517         }
   515 
   518 
   551         public MethodAttrInfo(CheckContext checkContext) {
   554         public MethodAttrInfo(CheckContext checkContext) {
   552             super(KindSelector.VAL, Infer.anyPoly, checkContext);
   555             super(KindSelector.VAL, Infer.anyPoly, checkContext);
   553         }
   556         }
   554 
   557 
   555         @Override
   558         @Override
   556         protected void attr(JCTree tree, Env<AttrContext> env) {
   559         protected boolean needsArgumentAttr(JCTree tree) {
   557             result = argumentAttr.attribArg(tree, env);
   560             return true;
   558         }
   561         }
   559 
   562 
   560         protected ResultInfo dup(Type newPt) {
   563         protected ResultInfo dup(Type newPt) {
   561             throw new IllegalStateException();
   564             throw new IllegalStateException();
   562         }
   565         }
   642         Env<AttrContext> prevEnv = this.env;
   645         Env<AttrContext> prevEnv = this.env;
   643         ResultInfo prevResult = this.resultInfo;
   646         ResultInfo prevResult = this.resultInfo;
   644         try {
   647         try {
   645             this.env = env;
   648             this.env = env;
   646             this.resultInfo = resultInfo;
   649             this.resultInfo = resultInfo;
   647             resultInfo.attr(tree, env);
   650             if (resultInfo.needsArgumentAttr(tree)) {
       
   651                 result = argumentAttr.attribArg(tree, env);
       
   652             } else {
       
   653                 tree.accept(this);
       
   654             }
   648             if (tree == breakTree &&
   655             if (tree == breakTree &&
   649                     resultInfo.checkContext.deferredAttrContext().mode == AttrMode.CHECK) {
   656                     resultInfo.checkContext.deferredAttrContext().mode == AttrMode.CHECK) {
   650                 throw new BreakAttr(copyEnv(env));
   657                 throw new BreakAttr(copyEnv(env));
   651             }
   658             }
   652             return result;
   659             return result;