langtools/src/share/classes/com/sun/tools/javac/comp/Infer.java
changeset 6934 258e5f06880f
parent 6710 b14e6fe7b290
child 7331 02ffc087c654
equal deleted inserted replaced
6933:6b9085d37f01 6934:258e5f06880f
   551         } else {
   551         } else {
   552             //The return type for a polymorphic signature call is computed from
   552             //The return type for a polymorphic signature call is computed from
   553             //the enclosing tree E, as follows: if E is a cast, then use the
   553             //the enclosing tree E, as follows: if E is a cast, then use the
   554             //target type of the cast expression as a return type; if E is an
   554             //target type of the cast expression as a return type; if E is an
   555             //expression statement, the return type is 'void' - otherwise the
   555             //expression statement, the return type is 'void' - otherwise the
   556             //return type is simply 'Object'.
   556             //return type is simply 'Object'. A correctness check ensures that
   557             switch (env.outer.tree.getTag()) {
   557             //env.next refers to the lexically enclosing environment in which
       
   558             //the polymorphic signature call environment is nested.
       
   559 
       
   560             switch (env.next.tree.getTag()) {
   558                 case JCTree.TYPECAST:
   561                 case JCTree.TYPECAST:
   559                     restype = ((JCTypeCast)env.outer.tree).clazz.type; break;
   562                     JCTypeCast castTree = (JCTypeCast)env.next.tree;
       
   563                     restype = (castTree.expr == env.tree) ?
       
   564                         castTree.clazz.type :
       
   565                         syms.objectType;
       
   566                     break;
   560                 case JCTree.EXEC:
   567                 case JCTree.EXEC:
   561                     restype = syms.voidType; break;
   568                     JCTree.JCExpressionStatement execTree =
       
   569                             (JCTree.JCExpressionStatement)env.next.tree;
       
   570                     restype = (execTree.expr == env.tree) ?
       
   571                         syms.voidType :
       
   572                         syms.objectType;
       
   573                     break;
   562                 default:
   574                 default:
   563                     restype = syms.objectType;
   575                     restype = syms.objectType;
   564             }
   576             }
   565         }
   577         }
   566 
   578