Bug 161541

Summary: [compiler][1.5] eclipse fails to compile when two methods are joined to one
Product: [Eclipse Project] JDT Reporter: Rémi Forax <forax>
Component: CoreAssignee: Kent Johnson <kent_johnson>
Status: VERIFIED FIXED QA Contact:
Severity: normal    
Priority: P3 CC: channingwalton, philippe_mulet
Version: 3.2   
Target Milestone: 3.3 M5   
Hardware: PC   
OS: Windows XP   
Whiteboard:

Description Rémi Forax CLA 2006-10-19 05:55:09 EDT
The code above doesn't compile with eclipse but compiles with javac (1.6 b99).

public class Join {
  abstract class C<A extends CharSequence,B> {
      abstract void m(A a);
      public void m(B b) {
          
      }
  }

  class D extends C<String,String> {
       
  }
}

The eclipse seems to report the error too early :
Duplicate methods named m with the parameters (B) and (A) are defined by the type Join.C<String,String>	java-patch/src	Join.java	line 10

The eclipse doesn't report an error if the two methods are specified in an interface so a possible workaround is to insert a fake interface :

public class Join {
  interface Fake<A extends CharSequence,B> {
      public void m(A a);
      public void m(B b);
  }
    
  abstract class C<A extends CharSequence,B> implements Fake<A,B>{
      public void m(B b) {
          
      }
  }
    
  class D extends C<String,String> {
       
  }
}

Rémi Forax
Comment 1 Kent Johnson CLA 2006-12-21 14:23:15 EST
We shouldn't complain about duplicates when a concrete method implements abstract methods because of type variable substitution.

Added MethodVerifyTest 120

Released for 3.3 M5 in HEAD stream
Comment 2 Olivier Thomann CLA 2007-02-05 11:28:57 EST
Verified for 3.3M5 using I20070205-0009.
Comment 3 Channing Walton CLA 2007-09-10 06:48:03 EDT
I've come across a similar problem which might be the same bug. I don't want to create a new bug if it is.

My code:

public class Foo<V, E> {

	public int getThing(V v) {
        return 1;
    }

    public boolean getThing(E e) {
            return true;
    }
}

public class Bar<V,E> extends Foo<V,E> {

}

The error is:
Duplicate methods named getThing with the parameters (E) and (V) are defined by the type Foo<V,E>

Is it the same?
Comment 4 Kent Johnson CLA 2007-09-10 12:52:53 EDT
Its definitely similar but not a duplicate of this bug.

Please open a new bug. thx