RFR: JDK-8046762, Revert some inference fixes in JDK-8033718
Dan Smith
daniel.smith at oracle.com
Fri Jun 13 17:23:14 UTC 2014
This is a 8u20 patch to get type inference in a stable state. It rolls back some changes in JDK-8033718 (and accompanying tests), rather than pushing forward with JDK-8039214 (which is the fix for 9).
All existing tests pass, including the test added for related bug JDK-8042656 (IntersectionSubVar.java).
—Dan
# HG changeset patch
# Parent e6d1e9f29132e71bd5d7095241e5fdb0223980bc
diff -r e6d1e9f29132 src/share/classes/com/sun/tools/javac/code/Type.java
--- a/src/share/classes/com/sun/tools/javac/code/Type.java Tue Jun 10 15:25:01 2014 -0600
+++ b/src/share/classes/com/sun/tools/javac/code/Type.java Fri Jun 13 11:02:45 2014 -0600
@@ -1658,9 +1658,6 @@
//only change bounds if request comes from substBounds
super.addBound(ib, bound, types, update);
}
- else if (bound.hasTag(UNDETVAR) && !((UndetVar) bound).isCaptured()) {
- ((UndetVar) bound).addBound(ib.complement(), this, types, false);
- }
}
@Override
diff -r e6d1e9f29132 src/share/classes/com/sun/tools/javac/code/Types.java
--- a/src/share/classes/com/sun/tools/javac/code/Types.java Tue Jun 10 15:25:01 2014 -0600
+++ b/src/share/classes/com/sun/tools/javac/code/Types.java Fri Jun 13 11:02:45 2014 -0600
@@ -1396,7 +1396,7 @@
// debugContainsType(t, s);
return isSameWildcard(t, s)
|| isCaptureOf(s, t)
- || ((t.isExtendsBound() || isSubtypeNoCapture(wildLowerBound(t), wildLowerBound(s))) &&
+ || ((t.isExtendsBound() || isSubtypeNoCapture(wildLowerBound(t), cvarLowerBound(wildLowerBound(s)))) &&
// TODO: JDK-8039214, cvarUpperBound call here is incorrect
(t.isSuperBound() || isSubtypeNoCapture(cvarUpperBound(wildUpperBound(s)), wildUpperBound(t))));
}
diff -r e6d1e9f29132 test/tools/javac/generics/inference/7086586/T7086586.out
--- a/test/tools/javac/generics/inference/7086586/T7086586.out Tue Jun 10 15:25:01 2014 -0600
+++ b/test/tools/javac/generics/inference/7086586/T7086586.out Fri Jun 13 11:02:45 2014 -0600
@@ -1,5 +1,5 @@
-T7086586.java:14:28: compiler.err.prob.found.req: (compiler.misc.inconvertible.types: compiler.misc.type.captureof: 1, ?, java.lang.String)
-T7086586.java:15:28: compiler.err.prob.found.req: (compiler.misc.inconvertible.types: compiler.misc.type.captureof: 1, ?, java.lang.Number)
-T7086586.java:16:31: compiler.err.prob.found.req: (compiler.misc.inconvertible.types: compiler.misc.type.captureof: 1, ?, java.lang.Exception)
-T7086586.java:17:13: compiler.err.cant.resolve.location.args: kindname.method, nonExistentMethod, , , (compiler.misc.location: kindname.interface, java.util.List<compiler.misc.type.captureof: 1, ?>, null)
+T7086586.java:14:20: compiler.err.cant.apply.symbol: kindname.method, m, java.util.List<? super T>, java.util.List<compiler.misc.type.captureof: 1, ?>, kindname.class, T7086586, (compiler.misc.infer.no.conforming.assignment.exists: T, (compiler.misc.inconvertible.types: java.util.List<compiler.misc.type.captureof: 1, ?>, java.util.List<? super T>))
+T7086586.java:15:20: compiler.err.cant.apply.symbol: kindname.method, m, java.util.List<? super T>, java.util.List<compiler.misc.type.captureof: 1, ?>, kindname.class, T7086586, (compiler.misc.infer.no.conforming.assignment.exists: T, (compiler.misc.inconvertible.types: java.util.List<compiler.misc.type.captureof: 1, ?>, java.util.List<? super T>))
+T7086586.java:16:23: compiler.err.cant.apply.symbol: kindname.method, m, java.util.List<? super T>, java.util.List<compiler.misc.type.captureof: 1, ?>, kindname.class, T7086586, (compiler.misc.infer.no.conforming.assignment.exists: T, (compiler.misc.inconvertible.types: java.util.List<compiler.misc.type.captureof: 1, ?>, java.util.List<? super T>))
+T7086586.java:17:9: compiler.err.cant.apply.symbol: kindname.method, m, java.util.List<? super T>, java.util.List<compiler.misc.type.captureof: 1, ?>, kindname.class, T7086586, (compiler.misc.infer.no.conforming.assignment.exists: T, (compiler.misc.inconvertible.types: java.util.List<compiler.misc.type.captureof: 1, ?>, java.util.List<? super T>))
4 errors
diff -r e6d1e9f29132 test/tools/javac/generics/inference/7086586/T7086586b.java
--- a/test/tools/javac/generics/inference/7086586/T7086586b.java Tue Jun 10 15:25:01 2014 -0600
+++ b/test/tools/javac/generics/inference/7086586/T7086586b.java Fri Jun 13 11:02:45 2014 -0600
@@ -23,10 +23,9 @@
/*
* @test
- * @bug 7086586 8033718
+ * @bug 7086586
*
- * @summary Inference producing null type argument; inference ignores capture
- * variable as upper bound
+ * @summary Inference producing null type argument
*/
import java.util.List;
@@ -41,8 +40,8 @@
assertionCount++;
}
- <T> void m(List<? super T> dummy) { assertTrue(true); }
- <T> void m(Object dummy) { assertTrue(false); }
+ <T> void m(List<? super T> dummy) { assertTrue(false); }
+ <T> void m(Object dummy) { assertTrue(true); }
void test(List<?> l) {
m(l);
diff -r e6d1e9f29132 test/tools/javac/generics/inference/NestedWildcards.java
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/test/tools/javac/generics/inference/NestedWildcards.java Fri Jun 13 11:02:45 2014 -0600
@@ -0,0 +1,44 @@
+/*
+ * Copyright (c) 2014, Oracle and/or its affiliates. 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 Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
+ * or visit www.oracle.com if you need additional information or have any
+ * questions.
+ */
+
+/*
+ * @test
+ * @bug 8046762
+ * @summary Nested generic methods that work on wildcard-parameterized types
+ * @compile NestedWildcards.java
+ */
+
+public class NestedWildcards {
+
+ public static void test(Box<String> b) {
+ foo(bar(b));
+ }
+ private static <X> Box<? extends X> foo(Box<? extends X> ts) {
+ return null;
+ }
+ public static <Y> Box<? extends Y> bar(Box<? extends Y> language) {
+ return null;
+ }
+
+ interface Box<T> {}
+}
More information about the compiler-dev
mailing list