JDK-7188968 : New instance creation expression using diamond is checked twice
  • Type: Sub-task
  • Component: tools
  • Sub-Component: javac
  • Affected Version: 8
  • Priority: P3
  • Status: Closed
  • Resolution: Fixed
  • OS: generic
  • CPU: unknown
  • Submitted: 2012-08-03
  • Updated: 2014-02-05
  • Resolved: 2012-09-26
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 8
8 b61Fixed
Description
The code in Attr.attribDiamond is designed to find a suitable consructor where class type-parameters are replaced by fresh inference variables - it is, in all aspects, a true overload resolution process - only performed on a set of slightly modified members - where all constructors have been turned into generic factory methods, according to the process described in the spec.

After diamond inference is completed, we can have two results:

*) a suitable constructor has been found so that inference is possible
*) no suitable constructor exists such that inference constraints can be satisfied

In the first case, we already know what is the symbol (and the type) iof the applicable constructor - so it would not be necessary (in principle) to apply another overload resolution step to look up those info.

The fact that the code is currently performing two lookups is problematic in terms of code evolution, as the code path for type-checking diamond is very different from the code for checking a generic method call with inference variables in the return type. This difference needs to be minimized moving forward, in order to take advantage of the new target-typing support in method context.

Comments
test: http://hg.openjdk.java.net/jdk8/tl/langtools/file/250f0acf880c/test/tools/javac/generics/diamond/7188968/T7188968.java
18-12-2012

Removed noreg-cleanup since a test for this bug was provided
27-10-2012

SUGGESTED FIX A webrev of this fix is available at the following URL: http://hg.openjdk.java.net/jdk8/tl/langtools/rev/db36841709e4
26-09-2012

EVALUATION Will do. It is necessary to keep track of the association between the original and the modified symbol, so that the attribution routine can set constructor symbol/type accordingly.
03-08-2012