1.1 --- a/src/share/classes/com/sun/tools/javac/comp/Check.java Tue Sep 25 11:53:18 2012 +0100 1.2 +++ b/src/share/classes/com/sun/tools/javac/comp/Check.java Tue Sep 25 11:55:34 2012 +0100 1.3 @@ -40,6 +40,8 @@ 1.4 import com.sun.tools.javac.code.Lint.LintCategory; 1.5 import com.sun.tools.javac.code.Type.*; 1.6 import com.sun.tools.javac.code.Symbol.*; 1.7 +import com.sun.tools.javac.comp.Infer.InferenceContext; 1.8 +import com.sun.tools.javac.comp.Infer.InferenceContext.FreeTypeListener; 1.9 1.10 import static com.sun.tools.javac.code.Flags.*; 1.11 import static com.sun.tools.javac.code.Flags.ANNOTATION; 1.12 @@ -429,6 +431,8 @@ 1.13 * Obtain a warner for this check context 1.14 */ 1.15 public Warner checkWarner(DiagnosticPosition pos, Type found, Type req); 1.16 + 1.17 + public Infer.InferenceContext inferenceContext(); 1.18 } 1.19 1.20 /** 1.21 @@ -455,6 +459,10 @@ 1.22 public Warner checkWarner(DiagnosticPosition pos, Type found, Type req) { 1.23 return enclosingContext.checkWarner(pos, found, req); 1.24 } 1.25 + 1.26 + public Infer.InferenceContext inferenceContext() { 1.27 + return enclosingContext.inferenceContext(); 1.28 + } 1.29 } 1.30 1.31 /** 1.32 @@ -471,6 +479,10 @@ 1.33 public Warner checkWarner(DiagnosticPosition pos, Type found, Type req) { 1.34 return convertWarner(pos, found, req); 1.35 } 1.36 + 1.37 + public InferenceContext inferenceContext() { 1.38 + return infer.emptyContext; 1.39 + } 1.40 }; 1.41 1.42 /** Check that a given type is assignable to a given proto-type. 1.43 @@ -483,7 +495,16 @@ 1.44 return checkType(pos, found, req, basicHandler); 1.45 } 1.46 1.47 - Type checkType(final DiagnosticPosition pos, Type found, Type req, CheckContext checkContext) { 1.48 + Type checkType(final DiagnosticPosition pos, final Type found, final Type req, final CheckContext checkContext) { 1.49 + final Infer.InferenceContext inferenceContext = checkContext.inferenceContext(); 1.50 + if (inferenceContext.free(req)) { 1.51 + inferenceContext.addFreeTypeListener(List.of(req), new FreeTypeListener() { 1.52 + @Override 1.53 + public void typesInferred(InferenceContext inferenceContext) { 1.54 + checkType(pos, found, inferenceContext.asInstType(req, types), checkContext); 1.55 + } 1.56 + }); 1.57 + } 1.58 if (req.tag == ERROR) 1.59 return req; 1.60 if (req.tag == NONE)