Bug 396634 - [move static members] Move method does not update return type if a type with the same name is already imported
Summary: [move static members] Move method does not update return type if a type with ...
Status: ASSIGNED
Alias: None
Product: JDT
Classification: Eclipse Project
Component: UI (show other bugs)
Version: 4.2.1   Edit
Hardware: PC Linux
: P3 normal (vote)
Target Milestone: ---   Edit
Assignee: JDT-UI-Inbox CLA
QA Contact:
URL:
Whiteboard: stalebug
Keywords:
Depends on:
Blocks:
 
Reported: 2012-12-14 11:30 EST by Milos Gligoric CLA
Modified: 2023-02-22 17:05 EST (History)
3 users (show)

See Also:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Milos Gligoric CLA 2012-12-14 11:30:47 EST
Steps to reproduce (Build id: 20121114-2344):
1. See instructions in code below
2. The resulting code does not compile ("Type mismatch: cannot convert from movemethod.id1.a.T to movemethod.id1.b.T")

package movemethod.id1.a;
public class T {
}

package movemethod.id1.b;
public @interface T {
}

package movemethod.id1;
import movemethod.id1.a.T;
public class C1 {
    // INVOKE "Move" REFACTORING ON METHOD "m1" AND SELECT "C2" AS THE DESTINATION
    public static T m1() {
        return new movemethod.id1.a.T(); // ***
    }
}

package movemethod.id1;
import movemethod.id1.b.T;
public class C2 {
    @T
    public void m2() {
    }
}

Note that the problem may not be noticed immediately if the line *** is replaced with "return null" and the same steps are performed.  In this case the resulting type of the method is modified, which should not be the case.

Somehow related to bug 71761.?
Comment 1 Martin Mathew CLA 2012-12-24 00:52:50 EST
Issue is reproducible using I20121210-0800. The refactoring results in compiler error.
Comment 2 Markus Keller CLA 2014-01-30 10:51:12 EST
The bug is that org.eclipse.jdt.internal.corext.refactoring.structure.MoveStaticMembersProcessor#getUpdatedMemberSource(RefactoringStatus, BodyDeclaration[], ITypeBinding) calls 

  ImportRewriteUtil.addImports(..., new HashMap<Name, String>(), ...)

The HashMaps actually do collect references that need to be rewritten, but this call just neglects the necessary updates.
Comment 3 Eclipse Genie CLA 2018-12-21 06:21:58 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 2020-12-11 07:06:50 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 5 Eclipse Genie CLA 2023-02-22 17:05:48 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.