File javac-fail.patch of Package java-1_6_0-openjdk
https://bugs.openjdk.java.net/show_bug.cgi?id=100136
diff -r 0ceb0a2667f9 -r 03661586b594 src/share/classes/com/sun/tools/javac/comp/Infer.java
--- a/src/share/classes/com/sun/tools/javac/comp/Infer.java Thu Oct 09 16:04:29 2008 +0100
+++ b/src/share/classes/com/sun/tools/javac/comp/Infer.java Thu Mar 25 11:28:39 2010 +0100
@@ -336,34 +336,46 @@
}
}
- // minimize as yet undetermined type variables
- for (Type t : undetvars)
- minimizeInst((UndetVar) t, warn);
+ // repeatedly minimize undetvars, and check against bounds
+ // until all type variables are instantiated to non bottom
+ // types or no further progress is made.
- /** Type variables instantiated to bottom */
- ListBuffer<Type> restvars = new ListBuffer<Type>();
+ //-System.err.println("undetvars="+undetvars);//DEBUG
+ //-System.err.println("targs="+targs);//DEBUG
- /** Instantiated types or TypeVars if under-constrained */
- ListBuffer<Type> insttypes = new ListBuffer<Type>();
+ ListBuffer<Type> restvars; // type variables instantiated to bottom
+ ListBuffer<Type> insttypes; // instance types.
+ int restlen = undetvars.length(); // length of restvars
+ int restlen1; // length of restvars in previous iteration
- /** Instantiated types or UndetVars if under-constrained */
- ListBuffer<Type> undettypes = new ListBuffer<Type>();
+ do {
+ // minimize as yet undetermined type variables
+ for (List<Type> l = undetvars; l.nonEmpty(); l = l.tail) {
+ minimizeInst((UndetVar) l.head, warn);
+ }
- for (Type t : undetvars) {
- UndetVar uv = (UndetVar)t;
- if (uv.inst.tag == BOT) {
- restvars.append(uv.qtype);
- insttypes.append(uv.qtype);
- undettypes.append(uv);
- uv.inst = null;
- } else {
- insttypes.append(uv.inst);
- undettypes.append(uv.inst);
- }
- }
- checkWithinBounds(tvars, undettypes.toList(), warn);
+ restvars = new ListBuffer<Type>();
+ insttypes = new ListBuffer<Type>();
+ ListBuffer<Type> insttypes1 = new ListBuffer<Type>();
+ // same as insttypes, except that UndetVars replace TypeVars.
+ for (List<Type> l = undetvars; l.nonEmpty(); l = l.tail) {
+ UndetVar uv = (UndetVar) l.head;
+ if (uv.inst.tag == BOT) {
+ restvars.append(uv.qtype);
+ insttypes.append(uv.qtype);
+ insttypes1.append(uv);
+ uv.inst = null;
+ } else {
+ insttypes.append(uv.inst);
+ insttypes1.append(uv.inst);
+ }
+ }
+ checkWithinBounds(tvars, insttypes1.toList(), warn);
+ restlen1 = restlen;
+ restlen = restvars.length();
+ } while (restlen != 0 && restlen != restlen1);
- if (!restvars.isEmpty()) {
+ if (restlen != 0) {
// if there are uninstantiated variables,
// quantify result type with them
mt = new MethodType(mt.argtypes,