Make internal: don't suggest for @JvmField property inside companion object of interface #KT-27138 Fixed
This commit is contained in:
committed by
Mikhail Glukhikh
parent
9cc93e9e55
commit
4abcd9a053
@@ -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");
|
||||
|
||||
Reference in New Issue
Block a user