fix: don't add @Override if super method is private (#976)

This commit is contained in:
Skylot
2020-09-17 16:37:23 +03:00
parent 91ee7565ac
commit cfaa6ab6df
2 changed files with 34 additions and 3 deletions
@@ -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");
}
}