Make internal: don't suggest in interface
#KT-35346 Fixed
This commit is contained in:
committed by
klunnii
parent
6e8565917e
commit
4144adf4ee
@@ -348,7 +348,10 @@ fun KtModifierListOwner.canBeProtected(): Boolean {
|
||||
}
|
||||
|
||||
fun KtModifierListOwner.canBeInternal(): Boolean {
|
||||
if (containingClass()?.isInterface() == true && hasJvmFieldAnnotation()) return false
|
||||
if (containingClass()?.isInterface() == true) {
|
||||
val objectDeclaration = getStrictParentOfType<KtObjectDeclaration>() ?: return false
|
||||
if (objectDeclaration.isCompanion() && hasJvmFieldAnnotation()) return false
|
||||
}
|
||||
return !isAnnotationClassPrimaryConstructor()
|
||||
}
|
||||
|
||||
|
||||
+7
@@ -0,0 +1,7 @@
|
||||
// WITH_RUNTIME
|
||||
interface KotlinInterface {
|
||||
object O {
|
||||
@JvmField
|
||||
<caret>val bar = Any()
|
||||
}
|
||||
}
|
||||
+7
@@ -0,0 +1,7 @@
|
||||
// WITH_RUNTIME
|
||||
interface KotlinInterface {
|
||||
object O {
|
||||
@JvmField
|
||||
internal val bar = Any()
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,4 @@
|
||||
// IS_APPLICABLE: false
|
||||
interface A {
|
||||
<caret>fun foo(name: String)
|
||||
}
|
||||
@@ -0,0 +1,5 @@
|
||||
interface KotlinInterface {
|
||||
companion object {
|
||||
<caret>val bar = Any()
|
||||
}
|
||||
}
|
||||
+5
@@ -0,0 +1,5 @@
|
||||
interface KotlinInterface {
|
||||
companion object {
|
||||
internal val bar = Any()
|
||||
}
|
||||
}
|
||||
+18
-3
@@ -3333,9 +3333,24 @@ public class IntentionTestGenerated extends AbstractIntentionTest {
|
||||
KotlinTestUtils.assertAllTestsPresentByMetadataWithExcluded(this.getClass(), new File("idea/testData/intentions/changeVisibility/internal"), Pattern.compile("^([\\w\\-_]+)\\.(kt|kts)$"), null, true);
|
||||
}
|
||||
|
||||
@TestMetadata("hasJvmFieldInInterface.kt")
|
||||
public void testHasJvmFieldInInterface() throws Exception {
|
||||
runTest("idea/testData/intentions/changeVisibility/internal/hasJvmFieldInInterface.kt");
|
||||
@TestMetadata("hasJvmFieldInInterfaceCompanion.kt")
|
||||
public void testHasJvmFieldInInterfaceCompanion() throws Exception {
|
||||
runTest("idea/testData/intentions/changeVisibility/internal/hasJvmFieldInInterfaceCompanion.kt");
|
||||
}
|
||||
|
||||
@TestMetadata("hasJvmFieldInInterfaceObject.kt")
|
||||
public void testHasJvmFieldInInterfaceObject() throws Exception {
|
||||
runTest("idea/testData/intentions/changeVisibility/internal/hasJvmFieldInInterfaceObject.kt");
|
||||
}
|
||||
|
||||
@TestMetadata("inInterface.kt")
|
||||
public void testInInterface() throws Exception {
|
||||
runTest("idea/testData/intentions/changeVisibility/internal/inInterface.kt");
|
||||
}
|
||||
|
||||
@TestMetadata("inInterfaceCompanion.kt")
|
||||
public void testInInterfaceCompanion() throws Exception {
|
||||
runTest("idea/testData/intentions/changeVisibility/internal/inInterfaceCompanion.kt");
|
||||
}
|
||||
|
||||
@TestMetadata("notForAnnotationClassPrimaryConstructor.kt")
|
||||
|
||||
Reference in New Issue
Block a user