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

changeset 845
5a43b245aed1
parent 832
57e3b9bc7fb8
child 895
9286a5d1fae3
     1.1 --- a/src/share/classes/com/sun/tools/javac/comp/Infer.java	Fri Jan 28 12:01:07 2011 +0000
     1.2 +++ b/src/share/classes/com/sun/tools/javac/comp/Infer.java	Fri Jan 28 12:03:49 2011 +0000
     1.3 @@ -1,5 +1,5 @@
     1.4  /*
     1.5 - * Copyright (c) 1999, 2010, Oracle and/or its affiliates. All rights reserved.
     1.6 + * Copyright (c) 1999, 2011, Oracle and/or its affiliates. All rights reserved.
     1.7   * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
     1.8   *
     1.9   * This code is free software; you can redistribute it and/or modify it
    1.10 @@ -485,11 +485,8 @@
    1.11                  @Override
    1.12                  public Type inst(List<Type> inferred, Types types) throws NoInstanceException {
    1.13                      List<Type> formals = types.subst(mt2.argtypes, tvars, inferred);
    1.14 -                    if (!rs.argumentsAcceptable(capturedArgs, formals,
    1.15 -                           allowBoxing, useVarargs, warn)) {
    1.16 -                      // inferred method is not applicable
    1.17 -                      throw invalidInstanceException.setMessage("inferred.do.not.conform.to.params", formals, argtypes);
    1.18 -                    }
    1.19 +                    // check that actuals conform to inferred formals
    1.20 +                    checkArgumentsAcceptable(env, capturedArgs, formals, allowBoxing, useVarargs, warn);
    1.21                      // check that inferred bounds conform to their bounds
    1.22                      checkWithinBounds(all_tvars,
    1.23                             types.subst(inferredTypes, tvars, inferred), warn);
    1.24 @@ -500,17 +497,27 @@
    1.25              }};
    1.26              return mt2;
    1.27          }
    1.28 -        else if (!rs.argumentsAcceptable(capturedArgs, mt.getParameterTypes(), allowBoxing, useVarargs, warn)) {
    1.29 -            // inferred method is not applicable
    1.30 -            throw invalidInstanceException.setMessage("inferred.do.not.conform.to.params", mt.getParameterTypes(), argtypes);
    1.31 -        }
    1.32          else {
    1.33 +            // check that actuals conform to inferred formals
    1.34 +            checkArgumentsAcceptable(env, capturedArgs, mt.getParameterTypes(), allowBoxing, useVarargs, warn);
    1.35              // return instantiated version of method type
    1.36              return mt;
    1.37          }
    1.38      }
    1.39      //where
    1.40  
    1.41 +        private void checkArgumentsAcceptable(Env<AttrContext> env, List<Type> actuals, List<Type> formals,
    1.42 +                boolean allowBoxing, boolean useVarargs, Warner warn) {
    1.43 +            try {
    1.44 +                rs.checkRawArgumentsAcceptable(env, actuals, formals,
    1.45 +                       allowBoxing, useVarargs, warn);
    1.46 +            }
    1.47 +            catch (Resolve.InapplicableMethodException ex) {
    1.48 +                // inferred method is not applicable
    1.49 +                throw invalidInstanceException.setMessage(ex.getDiagnostic());
    1.50 +            }
    1.51 +        }
    1.52 +
    1.53          /** Try to instantiate argument type `that' to given type `to'.
    1.54           *  If this fails, try to insantiate `that' to `to' where
    1.55           *  every occurrence of a type variable in `tvars' is replaced

mercurial