Bug 103528 - [1.5][compiler] compiler allows invalid assignment with method type parameter and nested wildcards
Summary: [1.5][compiler] compiler allows invalid assignment with method type parameter...
Status: VERIFIED FIXED
Alias: None
Product: JDT
Classification: Eclipse Project
Component: Core (show other bugs)
Version: 3.1   Edit
Hardware: PC Windows XP
: P3 normal (vote)
Target Milestone: 3.1.1   Edit
Assignee: Philipe Mulet CLA Friend
QA Contact:
URL:
Whiteboard:
Keywords:
Depends on:
Blocks:
 
Reported: 2005-07-12 14:47 EDT by Markus Keller CLA Friend
Modified: 2005-09-26 11:04 EDT (History)
1 user (show)

See Also:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Markus Keller CLA Friend 2005-07-12 14:47:48 EDT
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 ?>)
Comment 1 Philipe Mulet CLA Friend 2005-07-18 11:18:09 EDT
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.
Comment 2 Philipe Mulet CLA Friend 2005-07-18 11:29:20 EDT
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
Comment 3 Philipe Mulet CLA Friend 2005-07-19 05:41:34 EDT
Also added GenericTypeTest#test787.
Comment 4 Philipe Mulet CLA Friend 2005-07-19 12:08:22 EDT
Changed semantics for TypeBinding#isTypeArgumentIntersecting(...) to better
check situation where 2 upper bounds are specified.
Fixed
Comment 5 Maxime Daniel CLA Friend 2005-08-09 11:48:10 EDT
Verified in 3.2 M1 with build I20050808-2000.
Comment 6 David Audel CLA Friend 2005-09-26 11:04:26 EDT
Verified using M20050923-1430 for 3.1.1