Uploaded image for project: 'JDK'
  1. JDK
  2. JDK-6943278

spurious error message for inference and type-variable with erroneous bound

XMLWordPrintable

    • b128
    • unknown
    • generic
    • Verified

      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.

            mcimadamore Maurizio Cimadamore
            mcimadamore Maurizio Cimadamore
            Votes:
            0 Vote for this issue
            Watchers:
            0 Start watching this issue

              Created:
              Updated:
              Resolved:
              Imported:
              Indexed: