Bug 67643

Summary: [1.5] Incompatible conditional operand types
Product: [Eclipse Project] JDT Reporter: Igor Fedorenko <igor>
Component: CoreAssignee: Philipe Mulet <philippe_mulet>
Status: RESOLVED FIXED QA Contact:
Severity: normal    
Priority: P3    
Version: 3.0   
Target Milestone: 3.1 M1   
Hardware: PC   
OS: Windows 2000   
Whiteboard:

Description Igor Fedorenko CLA 2004-06-17 10:56:40 EDT
I do not know what JLS has to say about this, but the following code compiles by
javac 1.5 but not by cheetah. Error mesage is "Incompatible conditional operand
types C1 and C2"

--------------------------
package test.cheetah;
import java.util.ArrayList;
public class Test {
    private static class C1 extends ArrayList {
    }
    private static class C2 extends ArrayList {
    }
    ArrayList method(boolean param) {
        return param? new C1(): new C2();
    }
}
--------------------------

Note that javac 1.4.2 does not compile this code (error message "incompatible
types for ?: neither is a subtype of the other"). 

eclipse 200406111814, cheetah from CVS as of late afternoon June 16 EDT ;-)
Comment 1 Philipe Mulet CLA 2004-06-17 11:51:31 EDT
Interesting...
Comment 2 Igor Fedorenko CLA 2004-06-17 14:40:22 EDT
Out of curiosity, why eclipse/old javac complain about this? Target type of this
expression (ArrayList) is known and both C1 and C2 can be casted to that type,
so what's wrong whith that?
Comment 3 Philipe Mulet CLA 2004-06-30 07:59:24 EDT
Under JLS2, one of the operand has to be assignable to the other (i.e. C1 
assignable to C2 or reciprocal). It looks like JLS3 allow inference of most 
common supertype (which makes sense).
Comment 4 Philipe Mulet CLA 2004-06-30 07:59:57 EDT
New behavior is implemented from -source 1.5 on.
Comment 5 Philipe Mulet CLA 2004-06-30 10:13:18 EDT
Regression test added: Compliance_1_5#test080.
Comment 6 Philipe Mulet CLA 2004-06-30 10:13:36 EDT
Fixed