Make internal: don't suggest for @JvmField property inside companion object of interface #KT-27138 Fixed

This commit is contained in:
Toshiaki Kameyama
2018-11-27 00:33:10 +09:00
committed by Mikhail Glukhikh
parent 9cc93e9e55
commit 4abcd9a053
3 changed files with 18 additions and 1 deletions
@@ -310,7 +310,10 @@ fun KtModifierListOwner.canBeProtected(): Boolean {
}
}
fun KtModifierListOwner.canBeInternal(): Boolean = !isAnnotationClassPrimaryConstructor()
fun KtModifierListOwner.canBeInternal(): Boolean {
if (containingClass()?.isInterface() == true && hasJvmFieldAnnotation()) return false
return !isAnnotationClassPrimaryConstructor()
}
private fun KtModifierListOwner.isAnnotationClassPrimaryConstructor(): Boolean =
this is KtPrimaryConstructor && (this.parent as? KtClass)?.hasModifier(KtTokens.ANNOTATION_KEYWORD) ?: false
@@ -0,0 +1,9 @@
// IS_APPLICABLE: false
// WITH_RUNTIME
interface KotlinInterface {
companion object {
@JvmField
<caret>val bar = Any()
}
}
@@ -3560,6 +3560,11 @@ public class IntentionTestGenerated extends AbstractIntentionTest {
KotlinTestUtils.assertAllTestsPresentByMetadata(this.getClass(), new File("idea/testData/intentions/changeVisibility/internal"), Pattern.compile("^([\\w\\-_]+)\\.(kt|kts)$"), TargetBackend.ANY, true);
}
@TestMetadata("hasJvmFieldInInterface.kt")
public void testHasJvmFieldInInterface() throws Exception {
runTest("idea/testData/intentions/changeVisibility/internal/hasJvmFieldInInterface.kt");
}
@TestMetadata("notForAnnotationClassPrimaryConstructor.kt")
public void testNotForAnnotationClassPrimaryConstructor() throws Exception {
runTest("idea/testData/intentions/changeVisibility/internal/notForAnnotationClassPrimaryConstructor.kt");