Bug 80626 - [1.5] enum types cannot define a compareTo(Object o) method
Summary: [1.5] enum types cannot define a compareTo(Object o) method
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 M5   Edit
Assignee: Kent Johnson CLA
QA Contact:
URL:
Whiteboard:
Keywords:
Depends on:
Blocks:
 
Reported: 2004-12-09 14:20 EST by Olivier Thomann CLA
Modified: 2005-02-16 06:35 EST (History)
2 users (show)

See Also:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
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