Bug 99622 - [rename] Rename method misses ambiguously overridden method
Summary: [rename] Rename method misses ambiguously overridden method
Status: VERIFIED FIXED
Alias: None
Product: JDT
Classification: Eclipse Project
Component: UI (show other bugs)
Version: 3.1   Edit
Hardware: PC All
: P3 normal (vote)
Target Milestone: 4.24 M1   Edit
Assignee: Nikolay Metchev CLA
QA Contact: Jeff Johnston CLA
URL:
Whiteboard: stalebug
Keywords:
: 420265 (view as bug list)
Depends on:
Blocks: 395349 473034
  Show dependency tree
 
Reported: 2005-06-13 08:51 EDT by Tobias Widmer CLA
Modified: 2022-04-16 05:54 EDT (History)
8 users (show)

See Also:
noopur_gupta: review-
noopur_gupta: review-


Attachments
partial fix (26.73 KB, patch)
2013-10-25 05:39 EDT, Nikolay Metchev CLA
no flags Details | Diff
partial fix (26.86 KB, patch)
2013-10-25 06:03 EDT, Nikolay Metchev CLA
no flags Details | Diff
proper fix (41.21 KB, patch)
2013-10-28 06:49 EDT, Nikolay Metchev CLA
no flags Details | Diff

Note You need to log in before you can comment on or make changes to this bug.
Description Tobias Widmer CLA 2005-06-13 08:51:11 EDT
3.1 RC2

Consider following snippet:

class Top<E> {
    void add(E[] e) {}
    void add(String[] t) {};
}
class Sub extends Top<String> {
    void add(String... s) {}
}

-> Invoke rename refactoring on Top#add(E[])
-> Refactoring does not update declaration and method ripple of Top#add(String
[])
Comment 1 Dirk Baeumer CLA 2005-06-13 18:33:44 EDT
Markus, can you please comment on what the expected behaviour should be. IMO
this is a bug in search not find all potential declarations. If so please move
on to JDT/Core.
Comment 2 Markus Keller CLA 2005-06-14 03:50:42 EDT
Corner case. Although you can't call add(..) on a Top<String> due to an
ambiguous method invocation error, the methods are still related. All three
should be renamed at once.

This is probably a problem in the RippleMethodFinder, which currently assumes
that a type declares at most one related method.

Another problem is that search with IGNORE_DECLARING_TYPE | IGNORE_RETURN_TYPE,
only finds all three methods when started on Sub#add(..), and not when started
on a Top#add(..). Have to check whether we can blame the search engine on this. 
Comment 3 Martin Mathew CLA 2013-10-24 09:14:15 EDT
*** Bug 420265 has been marked as a duplicate of this bug. ***
Comment 4 Nikolay Metchev CLA 2013-10-25 05:39:10 EDT
Created attachment 236879 [details]
partial fix

This contribution complies with http://www.eclipse.org/legal/CoO.php

It seems there is an assumption in the code that you will only have one override per type. This patch removes that assumption from RippleMethodFinder2 and the Rename refactoring.

This doesn't fully fix the bug because the search engine doesn't "ripple" properly when you start from the supertype. 

It does however fix the problem that when you start from the subclass not all relevant super class methods are renamed.

I was experimenting with not using the search engine for RippleMethodFinder2.findAllDeclarations as part of bug 351410 which would have the benefit of addressing the rest of this bug. However I still think this partial patch is worthy of being committed.
Comment 5 Nikolay Metchev CLA 2013-10-25 06:03:42 EDT
Created attachment 236881 [details]
partial fix

This contribution complies with http://www.eclipse.org/legal/CoO.php

Missed out one header comment.
Comment 6 Nikolay Metchev CLA 2013-10-28 06:49:34 EDT
Created attachment 236949 [details]
proper fix

This contribution complies with http://www.eclipse.org/legal/CoO.php

Figured out how to fix this properly. This also fixes bug 395349.
Comment 7 Noopur Gupta CLA 2016-04-04 09:58:50 EDT
(In reply to Nikolay Metchev from comment #6)
> Created attachment 236949 [details]
> proper fix
> 
> This contribution complies with http://www.eclipse.org/legal/CoO.php
> 
> Figured out how to fix this properly. This also fixes bug 395349.

Thanks for the patch, Nikolay. Could you please rebase your patch on the current master branch and upload it to Gerrit for review?
Comment 8 Eclipse Genie CLA 2016-04-05 12:01:30 EDT
New Gerrit change created: https://git.eclipse.org/r/69935
Comment 9 Noopur Gupta CLA 2016-04-06 07:42:55 EDT
(In reply to Nikolay Metchev from comment #6)
> Figured out how to fix this properly. This also fixes bug 395349.

(In reply to Eclipse Genie from comment #8)
> New Gerrit change created: https://git.eclipse.org/r/69935
 
I just tried the patch and found the following issue:

Place caret at the first method name in super type and press Alt+Shift+R (or, Ctrl+1 > Rename in workspace). The second method in super type does not enter the linked mode for rename (though it is updated at the end of the refactoring).
Comment 10 Nikolay Metchev CLA 2016-04-06 08:28:46 EDT
Aah.. well spotted Noopur,
I'll see if I can fix that.
Comment 11 Eclipse Genie CLA 2016-04-06 10:56:50 EDT
New Gerrit change created: https://git.eclipse.org/r/70037
Comment 12 Noopur Gupta CLA 2016-04-07 09:23:12 EDT
(In reply to Eclipse Genie from comment #11)
> New Gerrit change created: https://git.eclipse.org/r/70037

I still see the issue mentioned in comment #9 with the above patch set 1.

Also, the issue described in this bug report is applicable to "Ctrl+1 > Rename in file" as well, which is still broken.

For the next version of your patch, you can amend the existing Gerrit request (70037) instead of creating a new one.

You can take your time for the proper fix, as I will be able to do a detailed code review only after I am done with other feature work that needs to go in M7.
Comment 13 Nikolay Metchev CLA 2016-04-07 14:20:57 EDT
Hello Noopur,
I apologise, it seems I made a slight change just before I submitted the code review and didn't re-test.
Also, this is the first time I am using Gerrit and am still trying to get my head around how it all works. It seems I made a mistake there as well and created a new Gerrit task.
I hope to be able to do better shortly.
Nikolay
Comment 14 Noopur Gupta CLA 2016-04-23 03:23:15 EDT
Moving to 4.7.
Comment 15 Eclipse Genie CLA 2020-05-17 17:11:58 EDT
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.
Comment 17 Jeff Johnston CLA 2022-03-25 23:17:14 EDT
Released for 4.24 M1

Noopur's comment #9 has been addressed by the latest patch
Comment 18 Christian Dietrich CLA 2022-03-28 14:59:26 EDT
could this have caused 
https://github.com/eclipse/xtext-xtend/issues/1310
Comment 19 Eclipse Genie CLA 2022-03-28 17:08:25 EDT
New Gerrit change created: https://git.eclipse.org/r/c/jdt/eclipse.jdt.ui/+/192294
Comment 21 Jeff Johnston CLA 2022-04-06 15:15:56 EDT
Verified for 4.24 M1 using I20220406 build