Some Eclipse Foundation services are deprecated, or will be soon. Please ensure you've read this important communication.

Bug 351383

Summary: The pull up refactoring on methods of inner classes could result in broken code
Product: [Eclipse Project] JDT Reporter: Mohsen Vakilian <reprogrammer>
Component: UIAssignee: JDT-UI-Inbox <jdt-ui-inbox>
Status: CLOSED DUPLICATE QA Contact:
Severity: minor    
Priority: P3 CC: amj87.iitr, deepakazad, nchen, reprogrammer, snegara2
Version: 3.7   
Target Milestone: ---   
Hardware: PC   
OS: Linux   
Whiteboard:
Attachments:
Description Flags
The Eclipse project containing the minimal example that demonstrates the bug in the pull up refactoring none

Description Mohsen Vakilian CLA 2011-07-07 00:15:21 EDT
Build Identifier: 20110615-0604

While working on the CodingSpectator <http://codingspectator.cs.illinois.edu/> project, we tried the pull up refactoring on a piece of code whose structure was similar to the one I use below. We expected the refactoring tool to warn us about the erroneous output that it was going to generate.

Reproducible: Always

Steps to Reproduce:
1. Create a Java project that contains a Java file C.java with the following contents.
  abstract class D {
    abstract void m();
    static class D1 { }
  }
  class C {
    void m() { }
    class C1 extends D.D1 {
      void m() {
        C.this.m();
      }
    }
  }
2. Invoke the pull up method refactoring on method m in C1 to D1 in the above piece of code.
3. Eclipse will perform the refactoring but the resulting code will contain the compilation problem "No enclosing instance of the type C is accessible in scope". I think it would be better if the precondition checks prevent or warn the user about performing this refactoring.
Comment 1 Mohsen Vakilian CLA 2011-07-07 00:16:49 EDT
Created attachment 199221 [details]
The Eclipse project containing the minimal example that demonstrates the bug in the pull up refactoring

The attached Java project contains the piece of code I used to explain the bug.
Comment 2 Ayushman Jain CLA 2011-07-07 02:05:13 EDT
Moving to JDT/UI
Comment 3 Deepak Azad CLA 2011-10-18 21:46:17 EDT

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