| Summary: | [extract method] Compilation error on extracting to outer type | ||||||
|---|---|---|---|---|---|---|---|
| Product: | [Eclipse Project] JDT | Reporter: | Noopur Gupta <noopur_gupta> | ||||
| Component: | UI | Assignee: | JDT-UI-Inbox <jdt-ui-inbox> | ||||
| Status: | CLOSED WONTFIX | QA Contact: | |||||
| Severity: | normal | ||||||
| Priority: | P3 | CC: | nikolaymetchev | ||||
| Version: | 3.8 | ||||||
| Target Milestone: | --- | ||||||
| Hardware: | All | ||||||
| OS: | All | ||||||
| Whiteboard: | stalebug | ||||||
| Attachments: |
|
||||||
Created attachment 235603 [details] Starting point This contribution complies with http://www.eclipse.org/legal/CoO.php How about this for a starting point? 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. |
In the given example, perform Refactor > Extract Method after selecting "foo();". Give the destination type as 'C_outer'. We get compilation error in the extracted method that foo() is undefined for the type C_outer. ------------------------------------------------- public class C_outer { class C_inner { void foo() { } void test() { foo(); // extract to method } } } --------------------------- Results in: public class C_outer { class C_inner { void foo() { } void test() { extracted(); // extract to method } } public void extracted() { foo(); // compilation error here } } ------------------------------------------------- Same issue with interface methods also with destination type 'I_outer' (>= Java 1.8): interface I_outer { interface I_inner { static void foo() { } default void test() { foo(); // extract to method } } } We should check if the code being extracted is accessible from the specified destination type and handle it accordingly.