Bug 393734 - [extract method] A local remains uninitialized after initialization code is extracted to a method
Summary: [extract method] A local remains uninitialized after initialization code is e...
Status: ASSIGNED
Alias: None
Product: JDT
Classification: Eclipse Project
Component: UI (show other bugs)
Version: 4.2.1   Edit
Hardware: All All
: P3 normal (vote)
Target Milestone: ---   Edit
Assignee: JDT-UI-Inbox CLA
QA Contact:
URL:
Whiteboard: stalebug
Keywords:
Depends on:
Blocks:
 
Reported: 2012-11-06 19:00 EST by Milos Gligoric CLA
Modified: 2022-07-05 17:12 EDT (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 Milos Gligoric CLA 2012-11-06 19:00:51 EST
(Thanks to Yilong Li for helping to find this bug)

Steps to reproduce:
1. Invoke "Extract Method" on "(t = n()) == null" in code below
2. There is a compilation error in the resulting file.

class T {
}

public class ExtractMethodBug {

    void m() {
        T t;
        while ((t = n()) == null);
        run(t);
    }

    void run(T t) {
    }

    T n() {
        return null;
    }
}
Comment 1 Markus Keller CLA 2012-11-09 10:57:34 EST
The refactoring should find out that t is written in the extracted expression and that it is read afterwards in m(). Therefore, t should also be returned from the extracted method, which makes the return value ambiguous.
Comment 2 Eclipse Genie CLA 2020-06-21 00:55: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.

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 3 Eclipse Genie CLA 2022-07-05 17:12:07 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.

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.