Bug 155104 - Ternary with incompatible types is wrongly accepted.
Summary: Ternary with incompatible types is wrongly accepted.
Status: VERIFIED INVALID
Alias: None
Product: JDT
Classification: Eclipse Project
Component: Core (show other bugs)
Version: 3.2   Edit
Hardware: PC Windows XP
: P3 normal (vote)
Target Milestone: 3.3 M5   Edit
Assignee: Philipe Mulet CLA
QA Contact:
URL:
Whiteboard:
Keywords:
Depends on:
Blocks:
 
Reported: 2006-08-24 15:46 EDT by Brian Miller CLA
Modified: 2007-02-06 06:27 EST (History)
0 users

See Also:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
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