EVALUATION
There are two problems here:
1) javac's implementation of 15.12.2.7 ends up adding 'nulltype' as upper bound of inference variables
2) javac's implementation of 15.12.2.8, becauase of constraint propagation, can end up inferring 'nulltype' for a given type-variable.
Fixing (1) will be more complete, but also more risky, as it will introduce subtle overload resolution differences. Fixing only (2) will be less risky, as the overload resolution process will be overall still compliant with what's available in the JDK 7 branch.
|
SUGGESTED FIX
A fix for problem (2) [see evaluation] is the following:
--- old/src/share/classes/com/sun/tools/javac/comp/Infer.java 2011-09-07 12:52:52.080720015 +0100
+++ new/src/share/classes/com/sun/tools/javac/comp/Infer.java 2011-09-07 12:52:51.948682136 +0100
@@ -248,6 +248,13 @@
return !t.isErroneous();
}
};
+
+ private Filter<Type> botFilter = new Filter<Type>() {
+ @Override
+ public boolean accepts(Type t) {
+ return t.tag != BOT;
+ }
+ };
/** Instantiate undetermined type variable to the lub of all its lower bounds.
* Throw a NoInstanceException if this not possible.
@@ -470,7 +477,8 @@
UndetVar uv = (UndetVar)t;
if (uv.qtype == tv) {
switch (ck) {
- case EXTENDS: return uv.hibounds.appendList(types.subst(types.getBounds(tv), all_tvars, inferredTypes));
+ case EXTENDS: return Type.filter(uv.hibounds, botFilter)
+ .appendList(types.subst(types.getBounds(tv), all_tvars, inferredTypes));
case SUPER: return uv.lobounds;
case EQUAL: return uv.inst != null ? List.of(uv.inst) : List.<Type>nil();
}
--- old/test/tools/javac/Diagnostics/6862608/T6862608a.out 2011-09-07 12:52:52.536708693 +0100
+++ new/test/tools/javac/Diagnostics/6862608/T6862608a.out 2011-09-07 12:52:52.411688328 +0100
@@ -1,3 +1,3 @@
|