changeset 165:e62c8af01197 jdk6-b32

OPENJDK6-35: backport of JDK-6650759 to openjdk6 Summary: Inference of formal type parameter (unused in formal parameters) is not performed. Reviewed-by: aph Contributed-by: vkarnauk <vladislav@azulsystems.com>, nikgor <nikolay@azulsystems.com>, ikrylov <ivan@azulsystems.com>
author ikrylov
date Mon, 23 Jun 2014 17:25:14 +0400
parents c711bcdb18ea
children d176cbb923aa
files src/share/classes/com/sun/tools/javac/code/Type.java src/share/classes/com/sun/tools/javac/comp/Infer.java test/tools/javac/generics/inference/6302954/T6476073.java test/tools/javac/generics/inference/6638712/T6638712b.out test/tools/javac/generics/inference/6638712/T6638712e.out test/tools/javac/generics/inference/6650759/T6650759a.java test/tools/javac/generics/inference/6650759/T6650759b.java test/tools/javac/generics/inference/6650759/T6650759c.java test/tools/javac/generics/inference/6650759/T6650759d.java test/tools/javac/generics/inference/6650759/T6650759e.java test/tools/javac/generics/inference/6650759/T6650759f.java test/tools/javac/generics/inference/6650759/T6650759g.java test/tools/javac/generics/inference/6650759/T6650759h.java test/tools/javac/generics/inference/6650759/T6650759i.java test/tools/javac/generics/inference/6650759/T6650759j.java test/tools/javac/generics/inference/6650759/T6650759k.java test/tools/javac/generics/inference/6650759/T6650759l.java test/tools/javac/generics/inference/6650759/T6650759m.java test/tools/javac/generics/inference/6650759/T6650759m.out
diffstat 19 files changed, 698 insertions(+), 15 deletions(-) [+]
line wrap: on
line diff
--- a/src/share/classes/com/sun/tools/javac/code/Type.java	Fri Jun 20 16:52:01 2014 +0400
+++ b/src/share/classes/com/sun/tools/javac/code/Type.java	Mon Jun 23 17:25:14 2014 +0400
@@ -1063,7 +1063,7 @@
 
         /**
          * Replaces this ForAll's typevars with a set of concrete Java types
-         * and returns the instantiated generic type. Subclasses might override
+         * and returns the instantiated generic type. Subclasses should override
          * in order to check that the list of types is a valid instantiation
          * of the ForAll's typevars.
          *
@@ -1076,6 +1076,42 @@
             return types.subst(qtype, tvars, actuals);
         }
 
+        /**
+         * Kind of type-constraint derived during type inference
+         */
+        public enum ConstraintKind {
+            /**
+             * upper bound constraint (a type variable must be instantiated
+             * with a type T, where T is a subtype of all the types specified by
+             * its EXTENDS constraints).
+             */
+            EXTENDS,
+            /**
+             * lower bound constraint (a type variable must be instantiated
+             * with a type T, where T is a supertype of all the types specified by
+             * its SUPER constraints).
+             */
+            SUPER,
+            /**
+             * equality constraint (a type variable must be instantiated to the type
+             * specified by its EQUAL constraint.
+             */
+            EQUAL;
+        }
+
+        /**
+         * Get the type-constraints of a given kind for a given type-variable of
+         * this ForAll type. Subclasses should override in order to return more
+         * accurate sets of constraints.
+         *
+         * @param tv the type-variable for which the constraint is to be retrieved
+         * @param ck the constraint kind to be retrieved
+         * @return the list of types specified by the selected constraint
+         */
+        public List<Type> getConstraints(TypeVar tv, ConstraintKind ck) {
+            return List.nil();
+        }
+
         public Type map(Mapping f) {
             return f.apply(qtype);
         }
--- a/src/share/classes/com/sun/tools/javac/comp/Infer.java	Fri Jun 20 16:52:01 2014 +0400
+++ b/src/share/classes/com/sun/tools/javac/comp/Infer.java	Mon Jun 23 17:25:14 2014 +0400
@@ -28,6 +28,7 @@
 import com.sun.tools.javac.code.*;
 import com.sun.tools.javac.code.Symbol.*;
 import com.sun.tools.javac.code.Type.*;
+import com.sun.tools.javac.code.Type.ForAll.ConstraintKind;
 import com.sun.tools.javac.util.*;
 
 import static com.sun.tools.javac.code.Flags.*;
@@ -50,6 +51,7 @@
 
     Symtab syms;
     Types types;
+    Check chk;
     Resolve rs;
 
     public static Infer instance(Context context) {
@@ -63,6 +65,7 @@
         context.put(inferKey, this);
         syms = Symtab.instance(context);
         types = Types.instance(context);
+        chk = Check.instance(context);
         rs = Resolve.instance(context);
     }
 
@@ -256,14 +259,19 @@
                                 Warner warn) throws InferenceException {
         List<Type> undetvars = Type.map(that.tvars, fromTypeVarFun);
         for (List<Type> l = undetvars; l.nonEmpty(); l = l.tail) {
-            UndetVar v = (UndetVar) l.head;
+            UndetVar uv = (UndetVar) l.head;
+            TypeVar tv = (TypeVar)uv.qtype;
             ListBuffer<Type> hibounds = new ListBuffer<Type>();
-            for (List<Type> l1 = types.getBounds((TypeVar) v.qtype); l1.nonEmpty(); l1 = l1.tail) {
-                if (!l1.head.containsSome(that.tvars)) {
-                    hibounds.append(l1.head);
+            for (Type t : that.getConstraints(tv, ConstraintKind.EXTENDS).prependList(types.getBounds(tv))) {
+                if (!t.containsSome(that.tvars) && t.tag != BOT) {
+                    hibounds.append(t);
                 }
             }
-            v.hibounds = hibounds.toList();
+            List<Type> inst = that.getConstraints(tv, ConstraintKind.EQUAL);
+            if (inst.nonEmpty() && inst.head.tag != BOT) {
+                uv.inst = inst.head;
+            }
+            uv.hibounds = hibounds.toList();
         }
         Type qtype1 = types.subst(that.qtype, that.tvars, undetvars);
         if (!types.isSubtype(qtype1, to)) {
@@ -279,7 +287,7 @@
         List<Type> targs = Type.map(undetvars, getInstFun);
         targs = types.subst(targs, that.tvars, targs);
         checkWithinBounds(that.tvars, targs, warn);
-        return that.inst(targs, types);
+        return chk.checkType(warn.pos(), that.inst(targs, types), to);
     }
 
     /** Instantiate method type `mt' by finding instantiations of
@@ -355,6 +363,9 @@
         /** Type variables instantiated to bottom */
         ListBuffer<Type> restvars = new ListBuffer<Type>();
 
+        /** Undet vars instantiated to bottom */
+        final ListBuffer<Type> restundet = new ListBuffer<Type>();
+
         /** Instantiated types or TypeVars if under-constrained */
         ListBuffer<Type> insttypes = new ListBuffer<Type>();
 
@@ -365,6 +376,7 @@
             UndetVar uv = (UndetVar)t;
             if (uv.inst.tag == BOT) {
                 restvars.append(uv.qtype);
+                restundet.append(uv);
                 insttypes.append(uv.qtype);
                 undettypes.append(uv);
                 uv.inst = null;
@@ -385,17 +397,32 @@
             final MethodType mt2 = new MethodType(mt.argtypes, null, mt.thrown, syms.methodClass);
             mt2.restype = new ForAll(restvars.toList(), mt.restype) {
                 @Override
+                public List<Type> getConstraints(TypeVar tv, ConstraintKind ck) {
+                    for (Type t : restundet.toList()) {
+                        UndetVar uv = (UndetVar)t;
+                        if (uv.qtype == tv) {
+                            switch (ck) {
+                                case EXTENDS: return uv.hibounds;
+                                case SUPER: return uv.lobounds;
+                                case EQUAL: return uv.inst != null ? List.of(uv.inst) : List.<Type>nil();
+                            }
+                        }
+                    }
+                    return List.nil();
+                }
+
+                @Override
                 public Type inst(List<Type> inferred, Types types) throws NoInstanceException {
                     List<Type> formals = types.subst(mt2.argtypes, tvars, inferred);
-                   if (!rs.argumentsAcceptable(capturedArgs, formals,
+                    if (!rs.argumentsAcceptable(capturedArgs, formals,
                            allowBoxing, useVarargs, warn)) {
                       // inferred method is not applicable
                       throw invalidInstanceException.setMessage("inferred.do.not.conform.to.params", formals, argtypes);
-                   }
-                   // check that inferred bounds conform to their bounds
-                   checkWithinBounds(all_tvars,
+                    }
+                    // check that inferred bounds conform to their bounds
+                    checkWithinBounds(all_tvars,
                            types.subst(inferredTypes, tvars, inferred), warn);
-                   return super.inst(inferred, types);
+                    return super.inst(inferred, types);
             }};
             return mt2;
         }
--- a/test/tools/javac/generics/inference/6302954/T6476073.java	Fri Jun 20 16:52:01 2014 +0400
+++ b/test/tools/javac/generics/inference/6302954/T6476073.java	Mon Jun 23 17:25:14 2014 +0400
@@ -25,7 +25,6 @@
  * @test
  * @bug     6476073
  * @summary Capture using super wildcard of type variables doesn't work
- * @ignore awaiting for 6650759 (see bug report for a detailed evaluation)
  * @compile T6476073.java
  */
 
--- a/test/tools/javac/generics/inference/6638712/T6638712b.out	Fri Jun 20 16:52:01 2014 +0400
+++ b/test/tools/javac/generics/inference/6638712/T6638712b.out	Mon Jun 23 17:25:14 2014 +0400
@@ -1,2 +1,2 @@
-T6638712b.java:15:21: compiler.err.invalid.inferred.types: T, (- compiler.misc.inferred.do.not.conform.to.bounds: T6638712b<java.lang.Integer>, T6638712b<java.lang.String>)
+T6638712b.java:15:21: compiler.err.prob.found.req: (- compiler.misc.incompatible.types.1: (- compiler.misc.no.conforming.instance.exists: T, T, java.lang.String)), <T>T, java.lang.String
 1 error
--- a/test/tools/javac/generics/inference/6638712/T6638712e.out	Fri Jun 20 16:52:01 2014 +0400
+++ b/test/tools/javac/generics/inference/6638712/T6638712e.out	Mon Jun 23 17:25:14 2014 +0400
@@ -1,2 +1,2 @@
-T6638712e.java:18:26: compiler.err.invalid.inferred.types: X, (- compiler.misc.inferred.do.not.conform.to.params: T6638712e.Foo<? super java.lang.Object,? extends java.lang.Boolean>, T6638712e.Foo<java.lang.Boolean,java.lang.Boolean>)
+T6638712e.java:18:26: compiler.err.prob.found.req: (- compiler.misc.incompatible.types.1: (- compiler.misc.no.conforming.instance.exists: X, T6638712e.Foo<X,java.lang.String>, T6638712e.Foo<java.lang.Object,java.lang.String>)), <X>T6638712e.Foo<X,java.lang.String>, T6638712e.Foo<java.lang.Object,java.lang.String>
 1 error
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/test/tools/javac/generics/inference/6650759/T6650759a.java	Mon Jun 23 17:25:14 2014 +0400
@@ -0,0 +1,45 @@
+/*
+ * Copyright 2009 Sun Microsystems, Inc.  All Rights Reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation.
+ *
+ * This code is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ *
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa Clara,
+ * CA 95054 USA or visit www.sun.com if you need additional information or
+ * have any questions.
+ */
+
+/*
+ * @test
+ * @bug     6650759
+ * @author  mcimadamore
+ * @summary Inference of formal type parameter (unused in formal parameters) is not performed
+ * @compile T6650759a.java
+ */
+
+class T6650759a {
+
+    public static interface Interface<T> { }
+    public static class IntegerInterface implements Interface<Integer> { }
+
+    <I extends Interface<T>, T> T getGenericValue(I test) { return null; }
+
+    void testSet(Integer test) { }
+
+    void test() {
+        Integer test = getGenericValue(new IntegerInterface());
+        testSet(getGenericValue(new IntegerInterface()));
+    }
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/test/tools/javac/generics/inference/6650759/T6650759b.java	Mon Jun 23 17:25:14 2014 +0400
@@ -0,0 +1,52 @@
+/*
+ * Copyright 2009 Sun Microsystems, Inc.  All Rights Reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation.
+ *
+ * This code is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ *
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa Clara,
+ * CA 95054 USA or visit www.sun.com if you need additional information or
+ * have any questions.
+ */
+
+/*
+ * @test
+ * @bug     6650759
+ * @author  mcimadamore
+ * @summary Inference of formal type parameter (unused in formal parameters) is not performed
+ * @compile T6650759b.java
+ */
+
+public class T6650759b {
+
+    interface A<X extends A<X, Y>, Y extends B<X>> {}
+
+    static class B<X extends A<X, ?>> {}
+
+    interface C<X extends A<X, Y>, Y extends B<X>> {}
+
+    interface D<X extends A<X, Y>, Y extends B<X>> {}
+
+    static class E<X extends A<X, Y>, Y extends B<X>, W extends C<X, Y>> implements D<X, Y> {
+
+        static <X extends A<X, Y>, Y extends B<X>, W extends C<X, Y>> D<X, Y> of(W w) {
+            return null;
+        }
+    }
+
+    <X extends A<X, Y>, Y extends B<X>, W extends C<X, Y>, Z extends D<X, Y>> Z test(W w) {
+        return (Z) E.of(w);
+    }
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/test/tools/javac/generics/inference/6650759/T6650759c.java	Mon Jun 23 17:25:14 2014 +0400
@@ -0,0 +1,49 @@
+/*
+ * Copyright 2009 Sun Microsystems, Inc.  All Rights Reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation.
+ *
+ * This code is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ *
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa Clara,
+ * CA 95054 USA or visit www.sun.com if you need additional information or
+ * have any questions.
+ */
+
+/*
+ * @test
+ * @bug     6650759
+ * @summary Inference of formal type parameter (unused in formal parameters) is not performed
+ * @compile T6650759c.java
+ */
+
+import java.util.Collection;
+import java.util.Collections;
+
+public class T6650759c {
+
+  static interface A {}
+
+  static interface B<X extends A> {}
+
+  static interface C<X extends A, Y extends B<X>> {}
+
+  public static <T extends A, U extends B<T>> Collection<C<T,U>> get(U u) {
+    return null;
+  }
+
+  public <T extends A, U extends B<T>> Collection<C<T,U>> test(U u) {
+    return Collections.unmodifiableCollection(get(u));
+  }
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/test/tools/javac/generics/inference/6650759/T6650759d.java	Mon Jun 23 17:25:14 2014 +0400
@@ -0,0 +1,51 @@
+/*
+ * Copyright 2009 Sun Microsystems, Inc.  All Rights Reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation.
+ *
+ * This code is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ *
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa Clara,
+ * CA 95054 USA or visit www.sun.com if you need additional information or
+ * have any questions.
+ */
+
+/*
+ * @test
+ * @bug     6650759
+ * @summary Inference of formal type parameter (unused in formal parameters) is not performed
+ * @compile T6650759d.java
+ */
+
+public class T6650759d {
+
+    static abstract class A<X> {
+
+        static <T> A<T> m(Iterable<? extends T> elements) {
+            return null;
+        }
+    }
+
+    static abstract class B {}
+
+    static abstract class C<X extends B> {}
+
+    <U extends C<V>, V extends B> Iterable<V> get(U u) {
+        return null;
+    }
+
+    <U extends C<V>, V extends B> void m(U u) {
+        A<V> a = A.m(get(u));
+    }
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/test/tools/javac/generics/inference/6650759/T6650759e.java	Mon Jun 23 17:25:14 2014 +0400
@@ -0,0 +1,52 @@
+/*
+ * Copyright 2009 Sun Microsystems, Inc.  All Rights Reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation.
+ *
+ * This code is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ *
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa Clara,
+ * CA 95054 USA or visit www.sun.com if you need additional information or
+ * have any questions.
+ */
+
+/*
+ * @test
+ * @bug     6650759
+ * @summary Inference of formal type parameter (unused in formal parameters) is not performed
+ * @compile T6650759e.java
+ */
+
+import java.util.List;
+
+public class T6650759e {
+
+    static abstract class A<X extends B> {}
+
+    interface B<X extends A> extends D {}
+
+    static abstract class C<X extends D> {}
+
+    interface D {}
+
+    static abstract class E<X extends C<? extends B<?>>> {}
+
+    <U extends C<V>, V extends B<W>, W extends A<V>> W m1(E<U> e) {
+        return m2(e);
+    }
+
+    <U extends C<V>, V extends B<W>, W extends A<V>> W m2(E<U> e) {
+        return null;
+    }
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/test/tools/javac/generics/inference/6650759/T6650759f.java	Mon Jun 23 17:25:14 2014 +0400
@@ -0,0 +1,50 @@
+/*
+ * Copyright 2009 Sun Microsystems, Inc.  All Rights Reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation.
+ *
+ * This code is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ *
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa Clara,
+ * CA 95054 USA or visit www.sun.com if you need additional information or
+ * have any questions.
+ */
+
+/*
+ * @test
+ * @bug     6650759
+ * @summary Inference of formal type parameter (unused in formal parameters) is not performed
+ * @compile T6650759f.java
+ */
+
+import java.util.Collections;
+
+public class T6650759f {
+
+    interface A<X extends A> {}
+
+    static abstract class B<X extends B> implements A<X> {}
+
+    static abstract class C<X extends D> extends B<X> {}
+
+    static class D extends C<D> {}
+
+    <X extends B, Y extends B<X>> Iterable<X> m(Y node) {
+        return null;
+    }
+
+    public void test(D d) {
+        Iterable<D> ops = (true) ? Collections.singletonList(d) : m(d);
+    }
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/test/tools/javac/generics/inference/6650759/T6650759g.java	Mon Jun 23 17:25:14 2014 +0400
@@ -0,0 +1,59 @@
+/*
+ * Copyright 2009 Sun Microsystems, Inc.  All Rights Reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation.
+ *
+ * This code is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ *
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa Clara,
+ * CA 95054 USA or visit www.sun.com if you need additional information or
+ * have any questions.
+ */
+
+/*
+ * @test
+ * @bug     6650759
+ * @summary Inference of formal type parameter (unused in formal parameters) is not performed
+ * @compile T6650759g.java
+ */
+
+public class T6650759g {
+
+    static abstract class A<X extends A<X>> {}
+
+    static abstract class B<X extends A<X>> {}
+
+    interface C<X, Y> {}
+
+    static abstract class D<X extends A<X>, Y extends B<X>> implements C<X, Y> {}
+
+    static class E extends A<E> {}
+
+    static class F extends B<E> {}
+
+    static void test(Iterable<E> data) {
+        m3(m2(data, m1(F.class)));
+    }
+
+    static <X extends A<X>, Y extends B<X>> D<X, Y> m1(Class<Y> c) {
+        return null;
+    }
+
+    static <U, V> Iterable<V> m2(Iterable<U> x1, C<? super U, ? extends V> x2) {
+        return null;
+    }
+
+    static void m3(Iterable<F> data) {
+    }
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/test/tools/javac/generics/inference/6650759/T6650759h.java	Mon Jun 23 17:25:14 2014 +0400
@@ -0,0 +1,39 @@
+/*
+ * Copyright 2009 Sun Microsystems, Inc.  All Rights Reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation.
+ *
+ * This code is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ *
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa Clara,
+ * CA 95054 USA or visit www.sun.com if you need additional information or
+ * have any questions.
+ */
+
+/*
+ * @test
+ * @bug     6650759
+ * @summary Inference of formal type parameter (unused in formal parameters) is not performed
+ * @compile T6650759h.java
+ */
+class T6650759h<X, Y> {
+
+    <A> Object m(A a, T6650759h<?, ? super A> t) {
+        return null;
+    }
+
+    void test(T6650759h<?, Void> t) {
+        m(null, t);
+    }
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/test/tools/javac/generics/inference/6650759/T6650759i.java	Mon Jun 23 17:25:14 2014 +0400
@@ -0,0 +1,54 @@
+/*
+ * Copyright 2009 Sun Microsystems, Inc.  All Rights Reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation.
+ *
+ * This code is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ *
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa Clara,
+ * CA 95054 USA or visit www.sun.com if you need additional information or
+ * have any questions.
+ */
+
+/*
+ * @test
+ * @bug     6650759
+ * @summary Inference of formal type parameter (unused in formal parameters) is not performed
+ * @compile T6650759i.java
+ */
+public class T6650759i {
+
+    static class A<X extends A, Y extends B> {}
+
+    static class B<X extends B> {}
+
+    static class C<X extends A<X, Y>, Y extends B<Y>> {}
+
+    static <U extends A<U, V>, V extends B<V>> Class<U> m1(U x) {
+        return null;
+    }
+
+    static <U extends A<U, V>, V extends B<V>> U m2(Class<U> c) {
+        return null;
+    }
+
+    static <W, U extends A<U, V>, V extends B<V>> W m3(Class<W> c1, C<U, V> c2) {
+        return null;
+    }
+
+    static <U extends A<U, V>, V extends B<V>> void test(U u, C<U, V> c) {
+        m2(m1(u));
+        U res = m3(m1(u), c);
+    }
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/test/tools/javac/generics/inference/6650759/T6650759j.java	Mon Jun 23 17:25:14 2014 +0400
@@ -0,0 +1,54 @@
+/*
+ * Copyright 2009 Sun Microsystems, Inc.  All Rights Reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation.
+ *
+ * This code is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ *
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa Clara,
+ * CA 95054 USA or visit www.sun.com if you need additional information or
+ * have any questions.
+ */
+
+/*
+ * @test
+ * @bug     6650759
+ * @summary Inference of formal type parameter (unused in formal parameters) is not performed
+ * @compile T6650759j.java
+ */
+
+public class T6650759j {
+
+    static abstract class A<X extends A<X>> {}
+
+    static abstract class B<X extends B<X, Y>, Y> extends A<X> {}
+
+    static abstract class C<X extends C<X, Y>, Y> extends B<X, Y> {}
+
+    interface D {}
+
+    static class E extends C<E, D> {}
+
+    static abstract class F<X extends F<X, Y>, Y extends A<Y>> extends A<X> {}
+
+    static class G extends F<G, E> {}
+
+    static <X extends F<X, Y>, Y extends A<Y>> X m(Iterable<X> it) {
+        return null;
+    }
+
+    static G test(Iterable<G> c) {
+        return m(c);
+    }
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/test/tools/javac/generics/inference/6650759/T6650759k.java	Mon Jun 23 17:25:14 2014 +0400
@@ -0,0 +1,44 @@
+/*
+ * Copyright 2009 Sun Microsystems, Inc.  All Rights Reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation.
+ *
+ * This code is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ *
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa Clara,
+ * CA 95054 USA or visit www.sun.com if you need additional information or
+ * have any questions.
+ */
+
+/*
+ * @test
+ * @bug     6650759
+ * @summary Inference of formal type parameter (unused in formal parameters) is not performed
+ * @compile T6650759k.java
+ */
+
+public class T6650759k {
+
+    static class A<X extends A> {}
+
+    static class B<X extends B, Y extends A> {}
+
+    <U extends A<U>, V extends B<V, U>> Object m(Class<V> c) {
+        return null;
+    }
+
+    <U extends A<U>, V extends B<V, U>> void test(Class<V> c) {
+        m(c);
+    }
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/test/tools/javac/generics/inference/6650759/T6650759l.java	Mon Jun 23 17:25:14 2014 +0400
@@ -0,0 +1,46 @@
+/*
+ * Copyright 2009 Sun Microsystems, Inc.  All Rights Reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation.
+ *
+ * This code is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ *
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa Clara,
+ * CA 95054 USA or visit www.sun.com if you need additional information or
+ * have any questions.
+ */
+
+/*
+ * @test
+ * @bug     6650759
+ * @summary Inference of formal type parameter (unused in formal parameters) is not performed
+ * @compile T6650759l.java
+ */
+
+public class T6650759l {
+
+    public static interface A<X> {}
+
+    public static class B implements A<Integer> {}
+
+    public static <X extends A<Y>, Y> Y m1(X x) {
+        return null;
+    }
+
+    public static void m2(Integer i) {}
+
+    public static void test(B b) {
+        m2(m1(b));
+    }
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/test/tools/javac/generics/inference/6650759/T6650759m.java	Mon Jun 23 17:25:14 2014 +0400
@@ -0,0 +1,24 @@
+/*
+ * @test /nodynamiccopyright/
+ * @bug     6650759
+ * @summary Inference of formal type parameter (unused in formal parameters) is not performed
+ * @compile/fail/ref=T6650759m.out -XDrawDiagnostics T6650759m.java
+ */
+
+import java.util.*;
+
+class T6650759m {
+    <Z> List<? super Z> m(List<? extends List<? super Z>> ls) {
+        return ls.get(0);
+    }
+
+    void test() {
+        ArrayList<ArrayList<Integer>> lli = new ArrayList<ArrayList<Integer>>();
+        ArrayList<Integer> li = new ArrayList<Integer>();
+        li.add(2);
+        lli.add(li);
+        List<? super String> ls = m(lli);
+        ls.add("crash");
+        Integer i = li.get(1);
+    }
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/test/tools/javac/generics/inference/6650759/T6650759m.out	Mon Jun 23 17:25:14 2014 +0400
@@ -0,0 +1,2 @@
+T6650759m.java:20:36: compiler.err.prob.found.req: (- compiler.misc.incompatible.types), java.util.List<? super java.lang.Integer>, java.util.List<? super java.lang.String>
+1 error