Bug 107045 - [1.5][compiler] Compiler misses name clash with bounded class type parameter
Summary: [1.5][compiler] Compiler misses name clash with bounded class type parameter
Status: VERIFIED FIXED
Alias: None
Product: JDT
Classification: Eclipse Project
Component: Core (show other bugs)
Version: 3.2   Edit
Hardware: PC Windows XP
: P3 normal (vote)
Target Milestone: 3.1.2   Edit
Assignee: Kent Johnson CLA
QA Contact:
URL:
Whiteboard:
Keywords:
Depends on:
Blocks:
 
Reported: 2005-08-15 12:36 EDT by Markus Keller CLA
Modified: 2006-01-10 09:14 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 Markus Keller CLA 2005-08-15 12:36:37 EDT
I20050811-1530

class A<T extends Number> {
    void m(T t) { System.out.println("A: " + t); }
}

class B<S extends Integer> extends A<S> {
    @Override
    void m(S t) { System.out.println("B: " + t); }
}

class D extends B<Integer> {
    // @Override correctly rejected, but declaration wrongly accepted:
    void m(Number t) { System.out.println("D#m(Number): " + t); }
    @Override
    void m(Integer t) { System.out.println("D#m(Integer): " + t); }
}

public class Test {
	public static void main(String[] args) {
        D d= new D();
        d.m(1);
        d.m(1.1); // should not compile
        A<Integer> ai= d;
        ai.m(2);
        A araw= d;
        araw.m(3);
        araw.m(3.1); // should CCE @ run time
    }
}

javac 1.5.0_04: name clash: m(java.lang.Number) in override.test2.D and m(T) in
override.test2.A<java.lang.Integer> have the same erasure, yet neither overrides
the other
class D extends B<Integer> {
^
Comment 1 Kent Johnson CLA 2005-10-11 12:38:34 EDT
Added MethodVerify test71 & released into HEAD.
Comment 2 Kent Johnson CLA 2005-10-11 13:02:57 EDT
forgot to tag it as fixed
Comment 3 Kent Johnson CLA 2005-10-11 13:22:06 EDT
Also released fix into 3.1.2 stream
Comment 4 Frederic Fusier CLA 2006-01-10 07:35:10 EST
Verified for 3.1.2 using build M20060109-1200.
Comment 5 Frederic Fusier CLA 2006-01-10 09:14:11 EST
Verified for 3.2 M4 using build I20051215-1506.