langtools/src/share/classes/com/sun/tools/javac/comp/Attr.java
changeset 24609 5139d892e270
parent 24401 0d793293862a
child 24612 75dc732b45af
equal deleted inserted replaced
24608:71f05b7d5c10 24609:5139d892e270
  4676     class PostAttrAnalyzer extends TreeScanner {
  4676     class PostAttrAnalyzer extends TreeScanner {
  4677 
  4677 
  4678         private void initTypeIfNeeded(JCTree that) {
  4678         private void initTypeIfNeeded(JCTree that) {
  4679             if (that.type == null) {
  4679             if (that.type == null) {
  4680                 if (that.hasTag(METHODDEF)) {
  4680                 if (that.hasTag(METHODDEF)) {
  4681                     that.type = dummyMethodType();
  4681                     that.type = dummyMethodType((JCMethodDecl)that);
  4682                 } else {
  4682                 } else {
  4683                     that.type = syms.unknownType;
  4683                     that.type = syms.unknownType;
  4684                 }
  4684                 }
  4685             }
  4685             }
  4686         }
  4686         }
  4687 
  4687 
       
  4688         /* Construct a dummy method type. If we have a method declaration,
       
  4689          * and the declared return type is void, then use that return type
       
  4690          * instead of UNKNOWN to avoid spurious error messages in lambda
       
  4691          * bodies (see:JDK-8041704).
       
  4692          */
       
  4693         private Type dummyMethodType(JCMethodDecl md) {
       
  4694             Type restype = syms.unknownType;
       
  4695             if (md != null && md.restype.hasTag(TYPEIDENT)) {
       
  4696                 JCPrimitiveTypeTree prim = (JCPrimitiveTypeTree)md.restype;
       
  4697                 if (prim.typetag == VOID)
       
  4698                     restype = syms.voidType;
       
  4699             }
       
  4700             return new MethodType(List.<Type>nil(), restype,
       
  4701                                   List.<Type>nil(), syms.methodClass);
       
  4702         }
  4688         private Type dummyMethodType() {
  4703         private Type dummyMethodType() {
  4689             return new MethodType(List.<Type>nil(), syms.unknownType,
  4704             return dummyMethodType(null);
  4690                             List.<Type>nil(), syms.methodClass);
       
  4691         }
  4705         }
  4692 
  4706 
  4693         @Override
  4707         @Override
  4694         public void scan(JCTree tree) {
  4708         public void scan(JCTree tree) {
  4695             if (tree == null) return;
  4709             if (tree == null) return;