Bug 80626

Summary: [1.5] enum types cannot define a compareTo(Object o) method
Product: [Eclipse Project] JDT Reporter: Olivier Thomann <Olivier_Thomann>
Component: CoreAssignee: Kent Johnson <kent_johnson>
Status: VERIFIED FIXED QA Contact:
Severity: normal    
Priority: P3 CC: markus.kell.r, philippe_mulet
Version: 3.1   
Target Milestone: 3.1 M5   
Hardware: PC   
OS: Windows XP   
Whiteboard:

Description Olivier Thomann CLA 2004-12-09 14:20:30 EST
Using latest, I can compile that code successfully, but it should report a name
clash.

public enum X {
	;
	
	public int compareTo(Object o) {
		return 0;
	}
}
Comment 1 Markus Keller CLA 2004-12-13 05:41:47 EST
I20041208-1200: I guess this is the same problem: Eclipse compiles without error
and makes all m(..) override. Javac 1.5.0 spits errors (inline comments).

package override2;

public class Override2 {
	public static void main(String[] args) {
		A a= new A();
		B b= new B();
		C c= new C();
		
		a.m(new Integer(1));
		b.m(new Integer(2));
//		c.m(new Integer(3)); // after uncommenting, javac says:
// reference to m is ambiguous, both method m(java.lang.Object) in override2.B
// and method <E>m(E) in override2.C match
		
		a= b;
		a.m(new Integer(11));
		a= c;
		a.m(new Integer(12));
		
		b= c;
		b.m(new Integer(21));
	}
}

class A {
	public <E extends Object> void m(E e) {
		System.out.println("A: " + e);
	}
}
class B extends A {
	public void m(Object e) {
		System.out.println("B: " + e);
	}
}
class C extends B {
// javac says: name clash: <E>m(E) in override2.C and m(java.lang.Object) in
// override2.B have the same erasure, yet neither overrides the other
	public <E extends Object> void m(E e) {
		System.out.println("C: " + e);
	}
}
Comment 2 Kent Johnson CLA 2005-02-01 11:52:26 EST
Reworked our name clash detection.

Added MethodVerify test035
Comment 3 David Audel CLA 2005-02-16 06:35:42 EST
Verified in I20050215-2300