JDK-7162438 : Usage of diamond notation with ?: conditional operator
  • Type: Bug
  • Component: tools
  • Sub-Component: javac
  • Affected Version: 7
  • Priority: P4
  • Status: Resolved
  • Resolution: Cannot Reproduce
  • OS: linux,windows_7
  • CPU: x86
  • Submitted: 2012-04-18
  • Updated: 2013-03-06
  • Resolved: 2013-03-06
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
8Resolved
Related Reports
Duplicate :  
Relates :  
Description
FULL PRODUCT VERSION :


A DESCRIPTION OF THE PROBLEM :
The javac compiler can't handle the usage of diamond notation <> with ?: conditional operator.

The following code:
List<String> list = false ? null : new ArrayList<>();
doesn't compile with error:
 incompatible types
 required: List<String>
 found:    ArrayList<Object>


REPRODUCIBILITY :
This bug can be reproduced always.

Comments
This has been fixed as a result of the inference overhaul.
06-03-2013

EVALUATION This is not a bug - target-type information is not propagated in conditional operators. However it is possible that this will be fixed as a result of the inference improvements that are part of Project Lambda
19-04-2012