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

"Move Field" refactoring causes the assignment statement to change.

Open
#1,744 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

When moving the selected field i of class C to class B, before refactoring, j is assigned to 0, and after refactoring, j is assigned to 1.
Code before refactoring:
```java
public class A {
void m(){
int i= 0;
class B {
int j;
void k(){
j= i;
}
}
class C {
B b;
// move 'i' to class 'B'
int i=1;
}
};
}
```
Code after refactoring:
```java
public class A {
void m(){
int i= 0;
class B {
int j;
// move 'i' to class 'B'
int i=1;
void k(){
j= i;
}
}

class C {
B b;
}
};
}

```

Contributor guide

Open the contributing guide

Research direction

Start by reproducing the example through the Java editor's "Move Field" refactoring, using the before-and-after snippets in the issue. Verify that the assignment in B.k() still resolves to the outer i initialized to 0 after moving C.i; the refactoring is done when that behavior is preserved.

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
38/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.