diff --git a/idea/src/org/jetbrains/kotlin/idea/intentions/ChangeVisibilityModifierIntention.kt b/idea/src/org/jetbrains/kotlin/idea/intentions/ChangeVisibilityModifierIntention.kt index e6fd5bee093..799c3811f37 100644 --- a/idea/src/org/jetbrains/kotlin/idea/intentions/ChangeVisibilityModifierIntention.kt +++ b/idea/src/org/jetbrains/kotlin/idea/intentions/ChangeVisibilityModifierIntention.kt @@ -102,10 +102,13 @@ open class ChangeVisibilityModifierIntention protected constructor( } } + protected fun isAnnotationClassPrimaryConstructor(element: KtDeclaration) = element is KtPrimaryConstructor && (element.parent as? KtClass)?.hasModifier(KtTokens.ANNOTATION_KEYWORD) ?: false + class Public : ChangeVisibilityModifierIntention(KtTokens.PUBLIC_KEYWORD), HighPriorityAction class Private : ChangeVisibilityModifierIntention(KtTokens.PRIVATE_KEYWORD), HighPriorityAction { override fun applicabilityRange(element: KtDeclaration): TextRange? { + if (isAnnotationClassPrimaryConstructor(element)) return null return if (element.canBePrivate()) super.applicabilityRange(element) else null } } diff --git a/idea/testData/intentions/changeVisibility/private/notForAnnotationClassPrimaryConstructor.kt b/idea/testData/intentions/changeVisibility/private/notForAnnotationClassPrimaryConstructor.kt new file mode 100644 index 00000000000..5880d690c49 --- /dev/null +++ b/idea/testData/intentions/changeVisibility/private/notForAnnotationClassPrimaryConstructor.kt @@ -0,0 +1,2 @@ +// IS_APPLICABLE: false +annotation class C(val v: Int) \ No newline at end of file diff --git a/idea/tests/org/jetbrains/kotlin/idea/intentions/IntentionTestGenerated.java b/idea/tests/org/jetbrains/kotlin/idea/intentions/IntentionTestGenerated.java index 52ea8167278..66b5e9e57ec 100644 --- a/idea/tests/org/jetbrains/kotlin/idea/intentions/IntentionTestGenerated.java +++ b/idea/tests/org/jetbrains/kotlin/idea/intentions/IntentionTestGenerated.java @@ -2934,6 +2934,12 @@ public class IntentionTestGenerated extends AbstractIntentionTest { doTest(fileName); } + @TestMetadata("notForAnnotationClassPrimaryConstructor.kt") + public void testNotForAnnotationClassPrimaryConstructor() throws Exception { + String fileName = KotlinTestUtils.navigationMetadata("idea/testData/intentions/changeVisibility/private/notForAnnotationClassPrimaryConstructor.kt"); + doTest(fileName); + } + @TestMetadata("notForLocal.kt") public void testNotForLocal() throws Exception { String fileName = KotlinTestUtils.navigationMetadata("idea/testData/intentions/changeVisibility/private/notForLocal.kt");