eclipse-jdt / eclipse-jdt/eclipse.jdt.ui
[Bug][Inline Method Refactoring] Inline Method refactoring for input program contians Lambda in Method Argument produces uncompilable program
Nobody has claimed this yet.
- Dominant language
- Java
- Stars
- 59
- Forks
- 127
- Avg merge
- 1d 8h
- Merged PRs (30d)
- 37
Description
Steps to reproduce
- Create a class named A:
public class A {
void baseMethod(Runnable action) {
action.run();
}
}
- Then, create a class named B:
public class B extends A {
void derivedMethod() {
super.baseMethod(() -> System.out.println("Lambda Action"));
}
static void staticContextMethod(B obj) {
obj.derivedMethod(); // Inline call to derivedMethod()
}
}
- Left click
derivedMethod()inobj.derivedMethod();like I comment in class B. Then, right click -> Refactor -> Inline. Use default configuration to inline this method like following, click ok:
The program is successfully refactored without any warning or exception. The refactored program is following, which contains syntax error:
public class A {
void baseMethod(Runnable action) {
action.run();
}
}
public class B extends A {
void derivedMethod() {
super.baseMethod(() -> System.out.println("Lambda Action"));
}
static void staticContextMethod(B obj) {
super.baseMethod(() -> System.out.println("Lambda Action")); // syntax error
}
}
- If choose the first default configuration like following:
- The refactored program is following, which also contains syntax error:
public class A {
void baseMethod(Runnable action) {
action.run();
}
}
public class B extends A {
static void staticContextMethod(B obj) {
super.baseMethod(() -> System.out.println("Lambda Action")); // syntax error
}
}
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
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start at the Inline Method refactoring invoked on B.derivedMethod() from B.staticContextMethod(B obj), using the A and B reproducer in the issue. Check both default configurations and verify that the refactored program remains valid Java and compiles without the reported 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
- Clearly specified
- Newbie friendliness
- 35/100