Some Eclipse Foundation services are deprecated, or will be soon. Please ensure you've read this important communication.

Bug 99596

Summary: [Change Method Signature] incorrectly rewrites type variable with concrete type
Product: [Eclipse Project] JDT Reporter: Tobias Widmer <tobias_widmer>
Component: UIAssignee: Markus Keller <markus.kell.r>
Status: CLOSED WONTFIX QA Contact:
Severity: normal    
Priority: P3 CC: michschn
Version: 3.1   
Target Milestone: ---   
Hardware: PC   
OS: All   
Whiteboard: stalebug

Description Tobias Widmer CLA 2005-06-13 06:16:52 EDT
3.1 RC2

Steps to reproduce:
- Consider following snippet:

class Top<E> {
    void add(E e) {}
}
class Sub extends Top<String> {
    void add(String s) {}
}

- Invoke CMS, change String in Sub to Object...

-> E in Top is replaced by Object...
-> Should rewrite using E...
Comment 1 Dirk Baeumer CLA 2005-06-13 19:00:36 EDT
Markus, can you please investigate.
Comment 2 Markus Keller CLA 2005-06-15 10:06:59 EDT
That's a difficult problem. When you change Sub#add(String) to add(Object...),
then I can't change Top#add(E) to add(E...), since the methods would then not
override any more and introduce a name clash in Sub.

The current behavior is the best you can get in this situation, unless you
change the type argument in the extends clause (which we certainly won't do in
change method signature).

However, when you start the refactoring on Top#add(E) and change the type to
E..., then you currently get an error telling that the refactoring may fail, and
Sub#add(String) is changed to add(E...) instead of add(String...). This case
could be improved by playing the substitution rules, but that's IMO out of scope
for 3.1.
Comment 3 Dirk Baeumer CLA 2005-06-15 10:48:07 EDT
Unhappy, but fixing this really sounds to risky. However, we have to understand
this better in the 3.2 cycle. At least we should flag an error in this case to
warn the user about this problem.

Markus, can we detect this ?
Comment 4 Dirk Baeumer CLA 2005-06-16 05:28:19 EDT
Moving to 3.2 then.
Comment 5 Markus Keller CLA 2010-02-15 05:11:31 EST
*** Bug 302832 has been marked as a duplicate of this bug. ***
Comment 6 Michael Schneider CLA 2010-02-15 05:24:51 EST
3.2? ;)
Comment 7 Markus Keller CLA 2010-02-15 06:18:30 EST
> 3.2? ;)

You can always attach a patch to speed things up ;-).
Comment 8 Eclipse Genie CLA 2020-02-21 14:00:12 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. As such, we're closing this bug.

If you have further information on the current state of the bug, please add it and reopen this bug. 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.