Details

Bug

Resolution: Fixed

P5

8
Description
An equality constraint of the form "alpha = <null type>" reduces to a bound of the same form, per 18.2.4. Resolution has the invariant that <null type> is never produced, so it is incorrect to produce bounds involving <null type>.
Suggested fix:

 If S and T are proper types, the constraint reduces to true if S is the same as T (4.3.4), and false otherwise.
 ***Otherwise, if S or T is the null type, the constraint reduces to false.***
 Otherwise, if S is an inference variable, α, the constraint reduces to the bound α = T.
 Otherwise, if T is an inference variable, α, the constraint reduces to the bound S = α.
 Otherwise, ...

Fortunately, I don't believe it is currently possible to reach this point with <null type> (equality constraints usually come from type arguments, and <null type> cannot be a type argument), so this fix is purely about futureproofing and avoiding confusion.
Suggested fix:

 If S and T are proper types, the constraint reduces to true if S is the same as T (4.3.4), and false otherwise.
 ***Otherwise, if S or T is the null type, the constraint reduces to false.***
 Otherwise, if S is an inference variable, α, the constraint reduces to the bound α = T.
 Otherwise, if T is an inference variable, α, the constraint reduces to the bound S = α.
 Otherwise, ...

Fortunately, I don't believe it is currently possible to reach this point with <null type> (equality constraints usually come from type arguments, and <null type> cannot be a type argument), so this fix is purely about futureproofing and avoiding confusion.
Attachments
Issue Links
 relates to

JDK8033407 18.2.3: 'null' should never be an inference variable bound
 Closed