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

Raw inner class constructor ref should not perform diamond inference

XMLWordPrintable

    • b21

        See JDK-8029632 for a spec clarification: a constructor ref qualified by a raw type cannot perform diamond inference if that raw type is a non-static member of a raw type. Instead, it should be treated like a raw constructor invocation.

        class Outer<T> {
          class Inner1 {}
          class Inner2<U> {}

          // expected/actual: ok
          Supplier<Outer.Inner1> s1 = Outer.Inner1::new;
          // expected/actual: ok
          Supplier<Outer.Inner2> s2 = Outer.Inner2::new;
          // expected: unchecked conversion; actual: ok
          Supplier<Outer<T>.Inner1> s3 = Outer.Inner1::new;
          // expected: unchecked conversion; actual: inference error
          Supplier<Outer<T>.Inner2<String>> s4 = Outer.Inner2::new;
        }

        The inference error in the last case above makes it clear that javac is trying to perform diamond inference here.

              vromero Vicente Arturo Romero Zaldivar
              dlsmith Dan Smith
              Votes:
              0 Vote for this issue
              Watchers:
              5 Start watching this issue

                Created:
                Updated:
                Resolved: