Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Bug][Pull Up Refactoring] Pull up refactoring produce uncompilable code for lambda parameter #1823

Closed
RETester66 opened this issue Dec 2, 2024 · 1 comment · Fixed by #1854
Assignees
Labels
bug Something isn't working
Milestone

Comments

@RETester66
Copy link

Steps to reproduce

The input program is following:

public class A {
    public class BaseInner {
        void innerMethodLambda(Outer outer) {
            Runnable r = () -> {
                System.out.println(outer.x);
                outer.foo();
            };
            r.run();
        }
    }

    public class Outer {
        public int x = 0;
        public void foo(){};

        public class Inner extends BaseInner {
            void innerMethod() { // Pull this method up to class BaseInner
                innerMethodLambda(Outer.this);
            }
        }
    }
}

Left click innerMethod(), then right click -> Refactor -> Pull Up, use the default configuration shown below, click finish:

image

The refactoring is performed without any warning or exception. The refactored program is following, which contains syntax error:

image

Environment

OS Version

Windows 10, 64-bit Operating System, x64-based processor

Eclipse Version

Eclipse IDE for Enterprise Java and Web Developers (includes Incubating components)
Version: 2024-09 (4.33.0)
Build id: 20240905-0614

JDK Version

java version "22.0.1" 2024-04-16
Java(TM) SE Runtime Environment (build 22.0.1+8-16)
Java HotSpot(TM) 64-Bit Server VM (build 22.0.1+8-16, mixed mode, sharing)

@jukzi jukzi added the bug Something isn't working label Dec 2, 2024
@jukzi
Copy link
Contributor

jukzi commented Dec 2, 2024

The last issue in that area was #1533

@jjohnstn jjohnstn self-assigned this Dec 14, 2024
@jjohnstn jjohnstn added this to the 4.35 M1 milestone Dec 14, 2024
jjohnstn added a commit to jjohnstn/eclipse.jdt.ui-1 that referenced this issue Dec 14, 2024
- modify PullUpRefactoring.CheckInvalidOuterFieldAccess checker to
  also look for class.this references that won't be accessible after
  pulling up the method
- add new test to PullUpTests
- fixes eclipse-jdt#1823
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants