Skip to content

Commit

Permalink
Fix extract method refactoring to recognize a member class collision (#…
Browse files Browse the repository at this point in the history
…1761)

- modify ExtractMethodRefactoring.checkForMethodOverride() to also
  check for a member class
- add new test to ExtractMethodTests
- fixes #1758
  • Loading branch information
jjohnstn authored Nov 1, 2024
1 parent 26bf480 commit 324bdfd
Show file tree
Hide file tree
Showing 3 changed files with 24 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -564,7 +564,7 @@ protected RefactoringStatus checkForMethodOverride() {
if (obj instanceof IType resultType) {
try {
ASTNode typeDecl= null;
if (resultType.isLocal() || resultType.isAnonymous()) {
if (resultType.isLocal() || resultType.isAnonymous() || resultType.isMember()) {
ICompilationUnit icu= resultType.getCompilationUnit();
typeDecl= getTypeDeclaration(resultType, icu);
}
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
package invalidSelection;

public class A_testIssue1758 {
public void foo() {
/*]*/int i;/*[*/
}
}

class SubClass {
void extracted() {
}

class InnerClass extends A_testIssue1758 {
void testMethod() {
extracted();
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -2735,4 +2735,9 @@ public void testIssue1357_2() throws Exception {
public void testIssue1516() throws Exception {
invalidSelectionTest();
}

@Test
public void testIssue1758() throws Exception {
invalidSelectionTest();
}
}

0 comments on commit 324bdfd

Please sign in to comment.