RFR: 8029633: Raw inner class constructor ref should not perform diamond inference [v2]

Vicente Romero vromero at openjdk.org
Tue Oct 18 18:25:22 UTC 2022


> This PR is synchronizing the compiler with the spec, in particular with this portion of section `15.13.1 Compile-Time Declaration of a Method Reference`:
> 
> 
> – If the method reference expression has the form ClassType ::
>   [TypeArguments] new , then the potentially applicable methods are a set of
>   notional methods corresponding to the constructors of ClassType.
>   If ClassType is a raw type, but is not a non- static member type of a raw type,
>   the candidate notional member methods are those specified in §15.9.3 for a
>   class instance creation expression that uses <> to elide the type arguments to a
>   class. Otherwise, the candidate notional member methods are the constructors
>   of ClassType, treated as if they were methods with return type ClassType.
> 
> so javac should treat the code below as a raw constructor invocation:
> 
> 
> class Outer<T> {
>     class Inner<U> {}
> 
>     Supplier<Outer<T>.Inner<String>> s = Outer.Inner::new;
> }
> 
> currently javac is rejecting this code
> 
> TIA
> 
> PS. Please review the related CSR too

Vicente Romero has updated the pull request with a new target base due to a merge or a rebase. The incremental webrev excludes the unrelated changes brought in by the merge/rebase. The pull request contains two additional commits since the last revision:

 - Merge branch 'master' into JDK-8029633
 - 8029633: Raw inner class constructor ref should not perform diamond inference

-------------

Changes:
  - all: https://git.openjdk.org/jdk/pull/9784/files
  - new: https://git.openjdk.org/jdk/pull/9784/files/6c87afef..d8867430

Webrevs:
 - full: https://webrevs.openjdk.org/?repo=jdk&pr=9784&range=01
 - incr: https://webrevs.openjdk.org/?repo=jdk&pr=9784&range=00-01

  Stats: 210566 lines in 3986 files changed: 106516 ins; 80840 del; 23210 mod
  Patch: https://git.openjdk.org/jdk/pull/9784.diff
  Fetch: git fetch https://git.openjdk.org/jdk pull/9784/head:pull/9784

PR: https://git.openjdk.org/jdk/pull/9784


More information about the compiler-dev mailing list