Bug 76132 - [1.5][wildcards] Bound mismatch incorrectly diagnosed with type variable quantification
Summary: [1.5][wildcards] Bound mismatch incorrectly diagnosed with type variable quan...
Status: VERIFIED FIXED
Alias: None
Product: JDT
Classification: Eclipse Project
Component: Core (show other bugs)
Version: 3.1   Edit
Hardware: PC All
: P3 normal (vote)
Target Milestone: 3.1 M4   Edit
Assignee: Philipe Mulet CLA
QA Contact:
URL:
Whiteboard:
Keywords:
Depends on:
Blocks:
 
Reported: 2004-10-12 18:28 EDT by John Maraist CLA
Modified: 2004-12-14 12:18 EST (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 John Maraist CLA 2004-10-12 18:28:39 EDT
Our systems: 
 - Eclipse 3.1M2 
 - both Mandrake 10.0 
    and Windows 2000 
 
In the code below, there are two incorrectly 
reported errors in method goK about classes 
K1/K2. 
 
(1) Bound mismatch: The generic method kk(K1<B>) of type K1<A> is not 
applicable for the arguments (K1<YY>) since the type YY is not a valid 
substitute for the bounded parameter <B extends A> 
 
(2) Bound mismatch: The generic method kk(K1<B>) of type K1<A> is not 
applicable for the arguments (K1<ZZ>) since the type ZZ is not a valid 
substitute for the bounded parameter <B extends A> 
 
K1/K2/goK compile and run correctly under 
Sun JDK 1.5.0. 
 
Note that M1/M2 work correctly under this Eclipse. 
but fail under that Sun JDK 
(although L1/L2 work on both, implying M1/M2 should work). 
Reported this as their bug #6176664 
http://bugs.sun.com:80/bugdatabase/view_bug.do?bug_id=6176664 
in which they suggest reporting M1/M2 as a bug to Eclipse 
although we're of the opinion that Eclipse is right about M1/M2. 
(So to compile K1/K2 under Sun JDK, remove M1/M2 and their uses.) 
 
 
// // // Code begins here 
interface K1<A> { 
        public <B extends A> void kk(K1<B> x); 
} 
 
class K2<C> implements K1<C> { 
        public <D extends C> void kk(K1<D> y) { 
                System.out.println("K2::kk(" + y.toString() + ")"); 
        } 
} 
 
// --------------------------------------------------- 
 
interface L1<E> { 
        public void ll(L1<? extends E> a); 
} 
 
class L2<KK> implements L1<KK> { 
        public void ll(L1<? extends KK> b) { 
                ll2(b); 
        } 
 
        private <LL extends KK> void ll2(L1<LL> c) { 
                System.out.println("L2::ll2(" + c.toString() + ")"); 
        } 
} 
 
// --------------------------------------------------- 
 
interface M1<H> { 
        public void mm(M1<? extends H> p); 
} 
 
class M2<I> implements M1<I> { 
        public <J extends I> void mm(M1<J> q) { 
                System.out.println("M2::mm(" + q.toString() + ")"); 
        } 
} 
 
// =================================================== 
 
class XX            { public String toString() { return "XX"; } } 
class YY extends XX { public String toString() { return "YY"; } } 
class ZZ extends YY { public String toString() { return "ZZ"; } } 
 
// --------------------------------------------------- 
 
class Exec { 
        public static void main(String arg[]) { 
                goK(new K2<YY>()); 
                goL(new L2<YY>()); 
                goM(new M2<YY>()); 
        } 
 
 
        public static void goK(K1<YY> k) { 
                // k.kk(new K2<XX>()); // Would fail 
                k.kk(new K2<YY>()); 
                k.kk(new K2<ZZ>()); 
        } 
 
 
        public static void goL(L1<YY> l) { 
                // l.ll(new L2<XX>()); // Would fail 
                l.ll(new L2<YY>()); 
                l.ll(new L2<ZZ>()); 
        } 
 
 
        public static void goM(M1<YY> m) { 
                // m.mm(new M2<XX>()); // Would fail 
                m.mm(new M2<YY>()); 
                m.mm(new M2<ZZ>()); 
        } 
}
Comment 1 Frederic Fusier CLA 2004-10-27 10:35:27 EDT
JDT compiler still complains with last build I200410260800.
Comment 2 Frederic Fusier CLA 2004-11-02 11:49:32 EST
We get now one additional compiler problem:
"Name clash : The method mm(M1<J>) of type M2<I> has the same erasure as mm(M1<?
extends H>) of type M1<I> but does not override it"
Comment 3 Philipe Mulet CLA 2004-11-09 06:47:41 EST
Adjusted code for better substituting through generic method declaring class.
Added regression test: GenericTypeTest#test397.

Fixed
Comment 4 Philipe Mulet CLA 2004-11-09 06:49:00 EST
Note that we still issue the nameclash issue:
"Name clash : The method mm(M1<J>) of type M2<I> has the same erasure as mm(M1<?
extends H>) of type M1<I> but does not override it"
Comment 5 Olivier Thomann CLA 2004-12-14 12:18:47 EST
Verified in 200412140800