Bug 155104

Summary: Ternary with incompatible types is wrongly accepted.
Product: [Eclipse Project] JDT Reporter: Brian Miller <bmiller>
Component: CoreAssignee: Philipe Mulet <philippe_mulet>
Status: VERIFIED INVALID QA Contact:
Severity: normal    
Priority: P3    
Version: 3.2   
Target Milestone: 3.3 M5   
Hardware: PC   
OS: Windows XP   
Whiteboard:

Description Brian Miller CLA 2006-08-24 15:46:27 EDT
Javac rightly rejects the ternary expression for having "incompatible types".  But Eclipse wrongly accepts it.

-----------------Bug.java-----------------
class Bug{
   java.io.Serializable field=this==null?8:"".getBytes();
}
Comment 1 Olivier Thomann CLA 2006-08-24 17:40:22 EDT
Seems to be a consequence of boxing.
Comment 2 Olivier Thomann CLA 2006-08-24 17:45:14 EDT
valueIfTrue type ends up being java.lang.Integer.
valueIfFalse type ends up being byte[].
The lub of both types is java.io.Serializable.
Comment 3 Philipe Mulet CLA 2007-01-10 06:52:02 EST
Both javac 6(b105) and 7(b05) agree with us. This is a bug in javac 5.
Closing as invalid.

Added AutoboxingTest#test129