Some Eclipse Foundation services are deprecated, or will be soon. Please ensure you've read this important communication.
Bug 507105 - [extract method] Extract method with 'replace additional occurrences' produces compile error
Summary: [extract method] Extract method with 'replace additional occurrences' produce...
Status: CLOSED DUPLICATE of bug 479559
Alias: None
Product: JDT
Classification: Eclipse Project
Component: UI (show other bugs)
Version: 4.6   Edit
Hardware: PC All
: P3 normal (vote)
Target Milestone: ---   Edit
Assignee: JDT-UI-Inbox CLA
QA Contact:
URL:
Whiteboard:
Keywords:
Depends on:
Blocks:
 
Reported: 2016-11-05 12:07 EDT by Rüdiger Herrmann CLA
Modified: 2016-11-22 06:32 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 Rüdiger Herrmann CLA 2016-11-05 12:07:45 EDT
Given this snippet:

  import java.beans.Encoder;

  class ExtractMethodBug {
    void a() {
      Encoder encoder = new Encoder(); 
      encoder.remove( null );          
    }

    void b() {
      Encoder encoder = new Encoder();
      encoder.remove( null );
      if( encoder.getExceptionListener() != null ) {
      }
    }
  }

Select the entire body of method 'a' and select Extract Method. Make sure to check the 'Replace additional occurrences' option.

The extracted method returns void instead of the new instance and the code in method 'b' does not compile because the 'encoder' variable cannot be resolved.
Comment 1 Noopur Gupta CLA 2016-11-07 09:39:30 EST
Reproducible in Eclipse 3.8 also.
Comment 2 Noopur Gupta CLA 2016-11-22 06:32:43 EST

*** This bug has been marked as a duplicate of bug 479559 ***