JDK-7166552 : Inference: cleanup usage of Type.ForAll
  • Type: Sub-task
  • Component: tools
  • Sub-Component: javac
  • Affected Version: 8
  • Priority: P3
  • Status: Closed
  • Resolution: Fixed
  • OS: generic
  • CPU: unknown
  • Submitted: 2012-05-04
  • Updated: 2012-12-18
  • Resolved: 2012-06-12
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 b43Fixed
Related Reports
Relates :  
Relates :  
Description
Type.ForAll is currently used for two purposes:

*) To represent the type of a generic method declaration
*) To represent a partially instantiated return type that will be fully instantiated after method checking

The latter usage is a bit clumsy - javac does method type inference in two completely separate rounds, which means there has to be an (indirect) way to communicate results from the former stage to the latter. This role has been taken over by the ForAll class - meaning that when we check a partially instantiated method type against a target, we callback into the ForAll type and finish up inference. This is not very regular and leads to problems when trying to expand the scope of type-inference.

Comments
SUGGESTED FIX A webrev for this fix is available at the following URL: http://hg.openjdk.java.net/jdk8/tl/langtools/rev/af6a4c24f4e3
31-05-2012

EVALUATION We really need to throw the target type earlier into the inference machinery - we should still consider it AFTER overload resolution, as per JLS, but we should consider it before the subsequent assigment expression is being type-checked, otherwise all info about type-inference would have been gone by that stage.
04-05-2012