src/share/classes/com/sun/tools/javac/comp/Infer.java

changeset 1219
48ee63caaa93
parent 1186
51fb17abfc32
child 1226
97bec6ab1227
     1.1 --- a/src/share/classes/com/sun/tools/javac/comp/Infer.java	Tue Mar 06 13:26:36 2012 +0000
     1.2 +++ b/src/share/classes/com/sun/tools/javac/comp/Infer.java	Tue Mar 06 13:28:05 2012 +0000
     1.3 @@ -445,16 +445,19 @@
     1.4                      return List.nil();
     1.5                  }
     1.6                  @Override
     1.7 -                void check(List<Type> inferred, Types types) throws NoInstanceException {
     1.8 +                void instantiateReturnType(Type restype, List<Type> inferred, Types types) throws NoInstanceException {
     1.9 +                    Type owntype = new MethodType(types.subst(getParameterTypes(), tvars, inferred),
    1.10 +                                       restype,
    1.11 +                                       types.subst(getThrownTypes(), tvars, inferred),
    1.12 +                                       qtype.tsym);
    1.13                      // check that actuals conform to inferred formals
    1.14 -                    checkArgumentsAcceptable(env, capturedArgs, getParameterTypes(), allowBoxing, useVarargs, warn);
    1.15 +                    checkArgumentsAcceptable(env, capturedArgs, owntype.getParameterTypes(), allowBoxing, useVarargs, warn);
    1.16                      // check that inferred bounds conform to their bounds
    1.17                      checkWithinBounds(all_tvars,
    1.18                             types.subst(inferredTypes, tvars, inferred), warn);
    1.19 -                    if (useVarargs) {
    1.20 -                        chk.checkVararg(env.tree.pos(), getParameterTypes(), msym);
    1.21 -                    }
    1.22 -            }};
    1.23 +                    qtype = chk.checkMethod(owntype, msym, env, TreeInfo.args(env.tree), capturedArgs, useVarargs);
    1.24 +                }
    1.25 +            };
    1.26          }
    1.27          else {
    1.28              // check that actuals conform to inferred formals
    1.29 @@ -520,16 +523,7 @@
    1.30                  return qtype.map(f);
    1.31              }
    1.32  
    1.33 -            void instantiateReturnType(Type restype, List<Type> inferred, Types types) throws NoInstanceException {
    1.34 -                //update method type with newly inferred type-arguments
    1.35 -                qtype = new MethodType(types.subst(getParameterTypes(), tvars, inferred),
    1.36 -                                       restype,
    1.37 -                                       types.subst(UninferredMethodType.this.getThrownTypes(), tvars, inferred),
    1.38 -                                       UninferredMethodType.this.qtype.tsym);
    1.39 -                check(inferred, types);
    1.40 -            }
    1.41 -
    1.42 -            abstract void check(List<Type> inferred, Types types) throws NoInstanceException;
    1.43 +            abstract void instantiateReturnType(Type restype, List<Type> inferred, Types types);
    1.44  
    1.45              abstract List<Type> getConstraints(TypeVar tv, ConstraintKind ck);
    1.46  
    1.47 @@ -544,7 +538,7 @@
    1.48                      if (rs.verboseResolutionMode.contains(VerboseResolutionMode.DEFERRED_INST)) {
    1.49                          log.note(pos, "deferred.method.inst", msym, UninferredMethodType.this.qtype, newRestype);
    1.50                      }
    1.51 -                    return newRestype;
    1.52 +                    return UninferredMethodType.this.qtype.getReturnType();
    1.53                  }
    1.54                  @Override
    1.55                  public List<Type> getConstraints(TypeVar tv, ConstraintKind ck) {

mercurial