AddJvmOverloadsIntention: disable for annotation classes
#KT-36482 Fixed
This commit is contained in:
@@ -16,6 +16,7 @@ import org.jetbrains.kotlin.platform.jvm.isJvm
|
||||
import org.jetbrains.kotlin.psi.*
|
||||
import org.jetbrains.kotlin.psi.psiUtil.endOffset
|
||||
import org.jetbrains.kotlin.psi.psiUtil.startOffset
|
||||
import org.jetbrains.kotlin.utils.addToStdlib.safeAs
|
||||
|
||||
private val annotationFqName = FqName("kotlin.jvm.JvmOverloads")
|
||||
|
||||
@@ -44,6 +45,7 @@ class AddJvmOverloadsIntention : SelfTargetingIntention<KtModifierListOwner>(
|
||||
KotlinBundle.message("text.secondary.constructor") to valueParameterList.parameters
|
||||
}
|
||||
is KtPrimaryConstructor -> {
|
||||
if (element.parent.safeAs<KtClass>()?.isAnnotation() == true) return false
|
||||
val parameters = (element.valueParameterList ?: return false).parameters
|
||||
|
||||
// For primary constructors with all default values, a zero-arg constructor is generated anyway. If there's only one
|
||||
|
||||
+3
@@ -0,0 +1,3 @@
|
||||
// IS_APPLICABLE: false
|
||||
|
||||
annotation class OverloadedAnn(val s1: String<caret> = "abc", val s2: String = "abc")
|
||||
@@ -953,6 +953,11 @@ public class IntentionTestGenerated extends AbstractIntentionTest {
|
||||
runTest("idea/testData/intentions/addJvmOverloads/primaryConstructor.kt");
|
||||
}
|
||||
|
||||
@TestMetadata("primaryConstructorOnAnnotationClass.kt")
|
||||
public void testPrimaryConstructorOnAnnotationClass() throws Exception {
|
||||
runTest("idea/testData/intentions/addJvmOverloads/primaryConstructorOnAnnotationClass.kt");
|
||||
}
|
||||
|
||||
@TestMetadata("primaryConstructorOneWithDefault.kt")
|
||||
public void testPrimaryConstructorOneWithDefault() throws Exception {
|
||||
runTest("idea/testData/intentions/addJvmOverloads/primaryConstructorOneWithDefault.kt");
|
||||
|
||||
Reference in New Issue
Block a user