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][Extract Method Refactoring] Extract method refactoring for Generics in Local Class produces uncompilable program #1785

Open
RETester66 opened this issue Nov 6, 2024 · 0 comments

Comments

@RETester66
Copy link

Steps to reproduce

  1. Create a class named A:
public class A {
    void foo(Integer value) {
        class Local<T> {
            void bar(T param) {
                Runnable runnable = () -> {
                    System.out.println(param); // Extract method on this statement
                };
            }
        }
    }
}
  1. Select the statement System.out.println(param); like I comment. Then, right click -> Refactor -> Extract Method. Choose the Destination Type as A, the configuration to extract this method like following, click ok:

image

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

public class A {
    void foo(Integer value) {
        class Local<T> {
            void bar(T param) {
                Runnable runnable = () -> {
                    extracted(param); // Extract method on this statement
                };
            }
        }
    }

	private void extracted(T param) {// syntax error
		System.out.println(param);
	}
}

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)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant