fix: don't add @Override if super method is private (#976)
This commit is contained in:
@@ -53,9 +53,11 @@ public class OverrideMethodVisitor extends AbstractVisitor {
|
||||
ClassNode classNode = root.resolveClass(superType);
|
||||
if (classNode != null) {
|
||||
for (MethodNode mth : classNode.getMethods()) {
|
||||
String mthShortId = mth.getMethodInfo().getShortId();
|
||||
if (mthShortId.startsWith(signature)) {
|
||||
overrideList.add(mth);
|
||||
if (!mth.getAccessFlags().isPrivate()) {
|
||||
String mthShortId = mth.getMethodInfo().getShortId();
|
||||
if (mthShortId.startsWith(signature)) {
|
||||
overrideList.add(mth);
|
||||
}
|
||||
}
|
||||
}
|
||||
} else {
|
||||
|
||||
@@ -0,0 +1,29 @@
|
||||
package jadx.tests.integration.others;
|
||||
|
||||
import org.junit.jupiter.api.Test;
|
||||
|
||||
import jadx.tests.api.IntegrationTest;
|
||||
|
||||
import static jadx.tests.api.utils.assertj.JadxAssertions.assertThat;
|
||||
|
||||
public class TestOverridePrivateMethod extends IntegrationTest {
|
||||
|
||||
public static class TestCls {
|
||||
public static class BaseClass {
|
||||
private void a() {
|
||||
}
|
||||
}
|
||||
|
||||
public static class MyClass extends BaseClass {
|
||||
public void a() {
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@Test
|
||||
public void test() {
|
||||
assertThat(getClassNode(TestCls.class))
|
||||
.code()
|
||||
.doesNotContain("@Override");
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user