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

Diamond: compiler accepts erroneous code where diamond is used with non-generic inner class

XMLWordPrintable

    • b138
    • unknown
    • generic
    • Verified

      Compiler accepts the following code:

      class A<X> {
         class B { }

         B b = new B<>();
      }

      Moreover, error messages for the following code is misleading:

      class A<X> {
         class B { }

         B b = new A<>.B<>();
      }

      The above is rejected with:

      TestX.java:4: error: improperly formed type, type arguments given on a raw type
         B b = new A<>.B<>();
                        ^

      This should simply be a parser error.

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

              Created:
              Updated:
              Resolved:
              Imported:
              Indexed: