[jvm-lang] java: don't create private abstract methods (IDEA-186499)

This commit is contained in:
Daniil Ovchinnikov
2018-02-12 19:23:05 +03:00
parent d83875ca88
commit 3151924a52
3 changed files with 18 additions and 1 deletions

View File

@@ -83,11 +83,14 @@ private class JavaMethodRenderer(
private fun renderMethod(): PsiMethod {
val method = factory.createMethod(request.methodName, PsiType.VOID)
var modifiersToRender = requestedModifiers
val modifiersToRender = requestedModifiers.toMutableList()
if (targetClass.isInterface) {
modifiersToRender -= (visibilityModifiers + JvmModifier.ABSTRACT)
}
else if (abstract) {
if (modifiersToRender.remove(JvmModifier.PRIVATE)) {
modifiersToRender += JvmModifier.PROTECTED
}
modifiersToRender += JvmModifier.ABSTRACT
}

View File

@@ -0,0 +1,8 @@
// "Create abstract method 'foo' in 'A'" "true"
abstract class A {
void usage() {
foo();
}
protected abstract void foo();
}

View File

@@ -0,0 +1,6 @@
// "Create abstract method 'foo' in 'A'" "true"
abstract class A {
void usage() {
<caret>foo();
}
}