Community
Participate
Working Groups
3.1 method1 compiles, method2 fails. As far as I can tell, their typing should be the same. class Test { <Sup, E1 extends Sup, E2 extends Sup> Sup method1(boolean b, E1 e1, E2 e2) { if (b) return e1; else return e2; } <Sup, E1 extends Sup, E2 extends Sup> Sup method2(boolean b, E1 e1, E2 e2) { return b ? e1 : e2; } }
Agree it looks strange. Now the rules for conditional operator have been changed with 1.5 to infer most common supertype; which seems to yield Object. Interestingly, javac agrees with us.
just checked, it's a bug in javac too: http://bugs.sun.com/bugdatabase/view_bug.do?bug_id=5042462
Problem comes from that our LUB computation is performing erasure of supertypes, thus getting rid of type parameters. Added GenericTypeTest#test791 Fixed
Verified for 3.2M1 (I20050808-2000)
Verified using M20050923-1430 for 3.1.1