JDK-6943278 : spurious error message for inference and type-variable with erroneous bound
  • Type: Bug
  • Component: tools
  • Sub-Component: javac
  • Affected Version: 7
  • Priority: P4
  • Status: Closed
  • Resolution: Fixed
  • OS: generic
  • CPU: unknown
  • Submitted: 2010-04-13
  • Updated: 2011-03-08
  • Resolved: 2011-03-08
The Version table provides details related to the release that this issue/RFE will be addressed.

Unresolved : Release in which this issue/RFE will be addressed.
Resolved: Release in which this issue/RFE has been resolved.
Fixed : Release in which this issue/RFE has been fixed. The release containing this fix may be available for download as an Early Access Release or a General Availability Release.

To download the current JDK release, click here.
JDK 7
7 b128Fixed
Related Reports
Relates :  
Description
The following program generates a spurious error message:

class  Foo<X extends Number&NonExistentClass> { 
   <X> Foo<X> m() { return null;}
   Foo<?> f = m();
}

error:

TestX.java:2: cannot find symbol
class  Foo<X extends Number&NonExistentClass> { 
                            ^
  symbol: class NonExistentClass
TestX.java:4: type parameter ? is not within its bound
   Foo<?> f = m();
       ^
TestX.java:4: type parameters of <X>Foo<X> cannot be determined; no unique maximal instance exists for type variable X with upper bounds <any>,Object
   Foo<?> f = m();
               ^
  where X is a type-variable:
    X extends Object declared in method <X>m()
3 errors


The problematic line is this:

"instance exists for type variable X with upper bounds <any>,Object"

an erroneous type is spilling into the error message.

Comments
SUGGESTED FIX A webrev of this fix is available at the following URL: http://hg.openjdk.java.net/jdk7/tl/langtools/rev/19c900c703c6
24-01-2011

EVALUATION During type-inferenence we should either ignore erroneous bounds, or deal with them so that proper diagnostics are generated.
13-04-2010