Bug 487812 - Illegal overload with type variable
Summary: Illegal overload with type variable
Status: NEW
Alias: None
Product: JDT
Classification: Eclipse Project
Component: Core (show other bugs)
Version: 4.6   Edit
Hardware: PC Windows 10
: P3 normal (vote)
Target Milestone: ---   Edit
Assignee: JDT-Core-Inbox CLA
QA Contact:
URL:
Whiteboard: stalebug
Keywords: helpwanted
Depends on:
Blocks:
 
Reported: 2016-02-15 06:30 EST by yuhki nagise CLA
Modified: 2023-01-05 11:56 EST (History)
1 user (show)

See Also:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description yuhki nagise CLA 2016-02-15 06:30:24 EST
The following code compiles with Eclipse:

------------------------------------------------
public class Sample {
	public interface Foo {}
	public interface Bar {}
	
	public <T extends Foo&Bar> void xxx(T t){}
	public <T extends Bar&Foo> void xxx(T t){}
}
------------------------------------------------

Whereas it fails with javac 1.8.0_51:

------------------------------------------------
Sample.java:8: error: method <T>xxx(T) is already defined in class Sample
        public <T extends Bar&Foo> void xxx(T t){}
                                        ^
  where T is a type-variable:
    T extends Foo,Bar declared in method <T>xxx(T)
1 error
------------------------------------------------

and, it fails with Eclipse:

------------------------------------------------
public class SampleEx extends Sample{
	@Override
	public <T extends Foo & Bar> void xxx(T t) {}
	@Override
	public <T extends Bar & Foo> void xxx(T t) {}
}
------------------------------------------------

Name clash: The method xxx(T) of type SampleEx has the same erasure as xxx(T) of type Sample but does not override it

The method xxx(T) of type SampleEx must override or implement a supertype method
Comment 1 Eclipse Genie CLA 2019-01-20 13:50:35 EST
This bug hasn't had any activity in quite some time. Maybe the problem got resolved, was a duplicate of something else, or became less pressing for some reason - or maybe it's still relevant but just hasn't been looked at yet.

If you have further information on the current state of the bug, please add it. The information can be, for example, that the problem still occurs, that you still want the feature, that more information is needed, or that the bug is (for whatever reason) no longer relevant.

--
The automated Eclipse Genie.
Comment 2 Stephan Herrmann CLA 2019-01-20 14:52:14 EST
Comment 0 still holds, but I don't have the time to check JLS, which compiler is right and by which rule.

Everyone affected is invited to demonstrate that ecj deviates from JLS and how so. I am, e.g., not aware of any rule defining equivalence of type parameters or intersection types (bounds).

Note, that in the .class file both methods differ indeed, since one parameter is erased to Foo and the other to Bar.
Comment 3 Eclipse Genie CLA 2021-01-10 17:52:31 EST
This bug hasn't had any activity in quite some time. Maybe the problem got resolved, was a duplicate of something else, or became less pressing for some reason - or maybe it's still relevant but just hasn't been looked at yet.

If you have further information on the current state of the bug, please add it. The information can be, for example, that the problem still occurs, that you still want the feature, that more information is needed, or that the bug is (for whatever reason) no longer relevant.

--
The automated Eclipse Genie.
Comment 4 Eclipse Genie CLA 2023-01-05 11:56:05 EST
This bug hasn't had any activity in quite some time. Maybe the problem got resolved, was a duplicate of something else, or became less pressing for some reason - or maybe it's still relevant but just hasn't been looked at yet.

If you have further information on the current state of the bug, please add it. The information can be, for example, that the problem still occurs, that you still want the feature, that more information is needed, or that the bug is (for whatever reason) no longer relevant.

--
The automated Eclipse Genie.