langtools/src/jdk.compiler/share/classes/com/sun/tools/javac/comp/Infer.java
changeset 36995 e19153419efd
parent 36157 fdbf6c9be2ab
child 37003 12ece14d32e0
equal deleted inserted replaced
36706:ccbc5ff54c9a 36995:e19153419efd
   558                                             MethodSymbol spMethod,  // sig. poly. method or null if none
   558                                             MethodSymbol spMethod,  // sig. poly. method or null if none
   559                                             Resolve.MethodResolutionContext resolveContext,
   559                                             Resolve.MethodResolutionContext resolveContext,
   560                                             List<Type> argtypes) {
   560                                             List<Type> argtypes) {
   561         final Type restype;
   561         final Type restype;
   562 
   562 
   563         //The return type for a polymorphic signature call is computed from
   563         if (spMethod == null || types.isSameType(spMethod.getReturnType(), syms.objectType, true)) {
   564         //the enclosing tree E, as follows: if E is a cast, then use the
   564             // The return type of the polymorphic signature is polymorphic,
   565         //target type of the cast expression as a return type; if E is an
   565             // and is computed from the enclosing tree E, as follows:
   566         //expression statement, the return type is 'void' - otherwise the
   566             // if E is a cast, then use the target type of the cast expression
   567         //return type is simply 'Object'. A correctness check ensures that
   567             // as a return type; if E is an expression statement, the return
   568         //env.next refers to the lexically enclosing environment in which
   568             // type is 'void'; otherwise
   569         //the polymorphic signature call environment is nested.
   569             // the return type is simply 'Object'. A correctness check ensures
   570 
   570             // that env.next refers to the lexically enclosing environment in
   571         switch (env.next.tree.getTag()) {
   571             // which the polymorphic signature call environment is nested.
   572             case TYPECAST:
   572 
   573                 JCTypeCast castTree = (JCTypeCast)env.next.tree;
   573             switch (env.next.tree.getTag()) {
   574                 restype = (TreeInfo.skipParens(castTree.expr) == env.tree) ?
   574                 case TYPECAST:
   575                     castTree.clazz.type :
   575                     JCTypeCast castTree = (JCTypeCast)env.next.tree;
   576                     syms.objectType;
   576                     restype = (TreeInfo.skipParens(castTree.expr) == env.tree) ?
   577                 break;
   577                               castTree.clazz.type :
   578             case EXEC:
   578                               syms.objectType;
   579                 JCTree.JCExpressionStatement execTree =
   579                     break;
   580                         (JCTree.JCExpressionStatement)env.next.tree;
   580                 case EXEC:
   581                 restype = (TreeInfo.skipParens(execTree.expr) == env.tree) ?
   581                     JCTree.JCExpressionStatement execTree =
   582                     syms.voidType :
   582                             (JCTree.JCExpressionStatement)env.next.tree;
   583                     syms.objectType;
   583                     restype = (TreeInfo.skipParens(execTree.expr) == env.tree) ?
   584                 break;
   584                               syms.voidType :
   585             default:
   585                               syms.objectType;
   586                 restype = syms.objectType;
   586                     break;
       
   587                 default:
       
   588                     restype = syms.objectType;
       
   589             }
       
   590         } else {
       
   591             // The return type of the polymorphic signature is fixed
       
   592             // (not polymorphic)
       
   593             restype = spMethod.getReturnType();
   587         }
   594         }
   588 
   595 
   589         List<Type> paramtypes = argtypes.map(new ImplicitArgType(spMethod, resolveContext.step));
   596         List<Type> paramtypes = argtypes.map(new ImplicitArgType(spMethod, resolveContext.step));
   590         List<Type> exType = spMethod != null ?
   597         List<Type> exType = spMethod != null ?
   591             spMethod.getThrownTypes() :
   598             spMethod.getThrownTypes() :