langtools/src/share/classes/com/sun/tools/javac/comp/Attr.java
changeset 21488 4a69e26aa999
parent 21480 9d08c2d0fafd
child 21498 58c2486db8d0
--- a/langtools/src/share/classes/com/sun/tools/javac/comp/Attr.java	Tue Oct 22 10:08:49 2013 +0200
+++ b/langtools/src/share/classes/com/sun/tools/javac/comp/Attr.java	Tue Oct 22 13:54:49 2013 +0100
@@ -250,6 +250,14 @@
         Type owntype = found;
         if (!owntype.hasTag(ERROR) && !resultInfo.pt.hasTag(METHOD) && !resultInfo.pt.hasTag(FORALL)) {
             if (allowPoly && inferenceContext.free(found)) {
+                if ((ownkind & ~resultInfo.pkind) == 0) {
+                    owntype = resultInfo.check(tree, inferenceContext.asFree(owntype));
+                } else {
+                    log.error(tree.pos(), "unexpected.type",
+                            kindNames(resultInfo.pkind),
+                            kindName(ownkind));
+                    owntype = types.createErrorType(owntype);
+                }
                 inferenceContext.addFreeTypeListener(List.of(found, resultInfo.pt), new FreeTypeListener() {
                     @Override
                     public void typesInferred(InferenceContext inferenceContext) {
@@ -511,6 +519,15 @@
         protected ResultInfo dup(CheckContext newContext) {
             return new ResultInfo(pkind, pt, newContext);
         }
+
+        @Override
+        public String toString() {
+            if (pt != null) {
+                return pt.toString();
+            } else {
+                return "";
+            }
+        }
     }
 
     class RecoveryInfo extends ResultInfo {