Bug 388013 - [extract method] Can not extract method following break/continue statement
Summary: [extract method] Can not extract method following break/continue statement
Status: ASSIGNED
Alias: None
Product: JDT
Classification: Eclipse Project
Component: UI (show other bugs)
Version: 3.8   Edit
Hardware: All All
: P3 minor with 2 votes (vote)
Target Milestone: ---   Edit
Assignee: JDT-UI-Inbox CLA
QA Contact:
URL:
Whiteboard: stalebug
Keywords:
Depends on:
Blocks:
 
Reported: 2012-08-24 13:07 EDT by Martin von Zweigbergk CLA
Modified: 2023-01-28 14:31 EST (History)
7 users (show)

See Also:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Martin von Zweigbergk CLA 2012-08-24 13:07:25 EDT
Consider this snippet:

    int a = 1;
    while (a > 0) {
      if (a > 0) {
        break;
      }
      int b = 1;
      a = b;
    }

When trying to extract the last two lines in the loop (presumably to
become "a = get1();"), Eclipse tells me

  Ambiguous return value: Selected block modifies more than one local variable
  used in subsequent code. Affected variables are:

  int a
  int b

There seems to be no "subsequent code" touching "b". If I remove the
break statement, the refactoring works as I suspected.
Comment 1 Srikanth Sankaran CLA 2012-08-24 22:42:36 EDT
Forward to UI for comment
Comment 2 Martin Mathew CLA 2013-06-27 03:14:54 EDT
Issue is reproducible using Eclipse build id: I20130618-0800
The problem seems to be in ExtractMethodAnalyzer#analyzeSelection(..)
Comment 3 Dmitry -- CLA 2015-03-16 03:45:50 EDT
The issue is still reproducible using Eclipse Version: Luna Service Release 2 (4.4.2)Build id: 20150219-0600.
Comment 4 Eclipse Genie CLA 2020-09-05 14:26:48 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 5 Jeff Johnston CLA 2020-09-08 19:40:34 EDT
This problem is still reproducible with 4.17 build I20200818
Comment 6 Eclipse Genie CLA 2023-01-28 14:31:56 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.