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

"Move Field" refactoring causes calling field to change #1745

Open
assdfsdafasfa opened this issue Oct 29, 2024 · 0 comments
Open

"Move Field" refactoring causes calling field to change #1745

assdfsdafasfa opened this issue Oct 29, 2024 · 0 comments

Comments

@assdfsdafasfa
Copy link

Move the field ‘b’ in class C to class A. Before refactoring, the output of the m() method is 2, and after moving, the output is 1.
Code before refactoring:

public class A {
}
class B {
	void main() {
		final int b = 2;
		new A() {
			void m() {
				System.out.println(b);
			}
		};
	}
}
class C {
	A a;
	protected final int b = 1;
}

Code after refactoring:

public class A {
   protected final int b = 1;
}
class B {
   void main() {
   	final int b = 2;
   	new A() {
   		void m() {
   			System.out.println(b);
   		}
   	};
   }
}
class C {
   A a;
}
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