Bug 161541 - [compiler][1.5] eclipse fails to compile when two methods are joined to one
Summary: [compiler][1.5] eclipse fails to compile when two methods are joined to one
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.3 M5   Edit
Assignee: Kent Johnson CLA
QA Contact:
URL:
Whiteboard:
Keywords:
Depends on:
Blocks:
 
Reported: 2006-10-19 05:55 EDT by Rémi Forax CLA
Modified: 2007-09-10 12:52 EDT (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 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