Community
Participate
Working Groups
I20050627-1435 (3.1), maybe connected to / dup of bug 103485. Eclipse accepts this: class Hover { <T extends Collection<? extends Number>> T getLonger(T t1, T t2) { return t1.size() > t2.size() ? t1 : t2; } void m(HashSet<?> list, ArrayList<?> set) { getLonger(list, set); } } javac 1.5.0_04: 1 error: <T>getLonger(T,T) in xy.Hover cannot be applied to (java.util.HashSet<capture of ?>,java.util.ArrayList<capture of ?>)
T gets inferred to intersection type: AbstractCollection<? extends Object> & Cloneable & Serializable which then passes incorrectly the bound check for: <T extends Collection<? extends java.lang.Number>> Problem lies in compatiblity rules for intersection type, not detecting an obvious incompatibility.
Actually, problem is actually in test for type intersecting another one. '? extends Object' is tolerated as argument intersecting with: '? extends Number'. Added GenericTypeTest#test785-786
Also added GenericTypeTest#test787.
Changed semantics for TypeBinding#isTypeArgumentIntersecting(...) to better check situation where 2 upper bounds are specified. Fixed
Verified in 3.2 M1 with build I20050808-2000.
Verified using M20050923-1430 for 3.1.1