Summary: | [1.5][compiler] Ambiguous method error because methods don't override in eclipse | ||
---|---|---|---|
Product: | [Eclipse Project] JDT | Reporter: | Markus Keller <markus.kell.r> |
Component: | Core | Assignee: | Philipe Mulet <philippe_mulet> |
Status: | CLOSED FIXED | QA Contact: | |
Severity: | minor | ||
Priority: | P3 | CC: | kent_johnson |
Version: | 3.1 | ||
Target Milestone: | 3.1 RC2 | ||
Hardware: | PC | ||
OS: | Windows XP | ||
Whiteboard: |
Description
Markus Keller
2005-06-09 04:30:21 EDT
Changing Ex to be: class Ex<C> extends Top<C> { @Override <M> void method(C cEx, M mEx) { System.out.println("Ex"); } } is accepted by both Eclipse & javac. IMethodBinding#overrides() must have a bug if its not accepting this case. This case works 'properly' as it reports the unchecked warning: class Try { public static void main(String[] args) { new Ex().method2(new Integer(1)); } } class Top<TC> { <TM> void method2(TM mTop) { System.out.println("Top"); } } class Ex<C> extends Top<C> { @Override <M> void method2(M mEx) { System.out.println("Ex"); } } Here is the full case, where we currently fail the 2 messages sends with type args (all 4 should be unchecked warnings): class Try { public static void main(String[] args) { Ex ex= new Ex(); ex.method("Eclipse1", new Integer(1)); ex.method2(new Integer(1)); ex.method3(new Integer(1)); ex.method4(new Integer(1)); } } class Top<TC> { <TM> void method(TC cTop, TM mTop) { System.out.println("Top"); } <TM> void method2(TM mTop) { System.out.println("Top"); } void method3(TC cTop) { System.out.println("Top"); } <TM> void method4(TC cTop) { System.out.println("Top"); } } class Ex<C> extends Top<C> { @Override <M> void method(C cEx, M mEx) { System.out.println("Ex"); } @Override <M> void method2(M mEx) { System.out.println("Ex"); } @Override void method3(C cEx) { System.out.println("Ex"); } @Override <M> void method4(C cEx) { System.out.println("Ex"); } } This is only a problem with Raw types, this case works fine: class Try { public static void main(String[] args) { Ex<String> ex= new Ex<String>(); ex.method("Eclipse1", new Integer(1)); ex.method2(new Integer(1)); ex.method3("Eclipse1"); ex.method4("Eclipse1"); } } class Top<TC> { <TM> void method(TC cTop, TM mTop) { System.out.println("Top"); } <TM> void method2(TM mTop) { System.out.println("Top"); } void method3(TC cTop) { System.out.println("Top"); } <TM> void method4(TC cTop) { System.out.println("Top"); } } class Ex<C> extends Top<C> { @Override <M> void method(C cEx, M mEx) { System.out.println("Ex"); } @Override <M> void method2(M mEx) { System.out.println("Ex"); } @Override void method3(C cEx) { System.out.println("Ex"); } @Override <M> void method4(C cEx) { System.out.println("Ex"); } } Added MethodVerify test061 & 62. Needs to be uncommented when fix is released. this.tiebreakMethod = this.isRaw ? this : new ParameterizedGenericMethodBinding (this.originalMethod, (RawTypeBinding)null, this.environment); Tests enabled. Fix released for integration. Verified for 3.1 RC2 using build I20050610-0010 Verified in I20050610-1200. |