langtools/src/share/classes/com/sun/tools/javac/code/Types.java
changeset 16292 3be2cdacb3b3
parent 15718 8e54c8e43d38
child 16295 8b76e466f3cb
--- a/langtools/src/share/classes/com/sun/tools/javac/code/Types.java	Thu Feb 14 09:43:00 2013 -0800
+++ b/langtools/src/share/classes/com/sun/tools/javac/code/Types.java	Fri Feb 15 16:28:07 2013 +0000
@@ -356,26 +356,11 @@
             }
 
             public Type getType(Type site) {
-                if (capture(site) != site) {
-                    Type formalInterface = site.tsym.type;
-                    ListBuffer<Type> typeargs = ListBuffer.lb();
-                    List<Type> actualTypeargs = site.getTypeArguments();
-                    //simply replace the wildcards with its bound
-                    for (Type t : formalInterface.getTypeArguments()) {
-                        if (actualTypeargs.head.hasTag(WILDCARD)) {
-                            WildcardType wt = (WildcardType)actualTypeargs.head;
-                            typeargs.append(wt.type);
-                        } else {
-                            typeargs.append(actualTypeargs.head);
-                        }
-                        actualTypeargs = actualTypeargs.tail;
-                    }
-                    site = subst(formalInterface, formalInterface.getTypeArguments(), typeargs.toList());
-                    if (!chk.checkValidGenericType(site)) {
-                        //if the inferred functional interface type is not well-formed,
-                        //or if it's not a subtype of the original target, issue an error
-                        throw failure(diags.fragment("no.suitable.functional.intf.inst", site));
-                    }
+                site = removeWildcards(site);
+                if (!chk.checkValidGenericType(site)) {
+                    //if the inferred functional interface type is not well-formed,
+                    //or if it's not a subtype of the original target, issue an error
+                    throw failure(diags.fragment("no.suitable.functional.intf.inst", site));
                 }
                 return memberType(site, descSym);
             }
@@ -584,6 +569,27 @@
             return false;
         }
     }
+
+    public Type removeWildcards(Type site) {
+        if (capture(site) != site) {
+            Type formalInterface = site.tsym.type;
+            ListBuffer<Type> typeargs = ListBuffer.lb();
+            List<Type> actualTypeargs = site.getTypeArguments();
+            //simply replace the wildcards with its bound
+            for (Type t : formalInterface.getTypeArguments()) {
+                if (actualTypeargs.head.hasTag(WILDCARD)) {
+                    WildcardType wt = (WildcardType)actualTypeargs.head;
+                    typeargs.append(wt.type);
+                } else {
+                    typeargs.append(actualTypeargs.head);
+                }
+                actualTypeargs = actualTypeargs.tail;
+            }
+            return subst(formalInterface, formalInterface.getTypeArguments(), typeargs.toList());
+        } else {
+            return site;
+        }
+    }
     // </editor-fold>
 
    /**