eclipse-jdt / eclipse-jdt/eclipse.jdt.ui

[Bug][Pull Up Refactoring] Pull up refactoring for input program contians Lambda Accessing Super Methods produces uncompilable program

Open
#1,776 0 comments 0 reactions 0 assignees View on GitHub
Dominant language
Java
Stars
59
Forks
127
Avg merge
23h 30m
Merged PRs (30d)
35

Description

## Steps to reproduce
The input program is following:
```
public class A {
public class BaseTargetClass {
void superMethod() { System.out.println("Super method"); }
}

public class OriginalClass extends BaseTargetClass {

public class NestedOriginalClass extends BaseTargetClass {
void methodToBePulledUp() {
Runnable r = super::superMethod;
r.run();
}
}
}
}
```
Left click methodToBePulledUp(), then right click -> Refactor -> Pull Up, use the default configuration shown below, click finish:

![image](https://github.com/user-attachments/assets/0d348d35-d6e5-4bab-ad6f-4eda1aff03e7)

The refactoring is performed without any warning or exception. The refactored program is following, which contains syntax error:
```
public class A {
public class BaseTargetClass {
void superMethod() { System.out.println("Super method"); }

void methodToBePulledUp() {
Runnable r = super::superMethod;// syntax error
r.run();
}
}

public class OriginalClass extends BaseTargetClass {

public class NestedOriginalClass extends BaseTargetClass {
}
}
}
```
## 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)

Contributor guide

Open the contributing guide

Research direction

Reproduce the issue with the Java input program and the Pull Up refactoring described above, then inspect the refactoring's handling of a lambda method reference to super. Add a regression check for this case and verify that the refactoring either prevents the invalid transformation or produces compilable Java without silently accepting a syntax error.

Written by the indexing model from the issue text.

Assessment

Tech stack
java
Domain
tooling
Issue type
Bug
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
45/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.