diff --git a/idea/src/org/jetbrains/kotlin/idea/intentions/MovePropertyToClassBodyIntention.kt b/idea/src/org/jetbrains/kotlin/idea/intentions/MovePropertyToClassBodyIntention.kt index 299c909f222..dba956827bd 100644 --- a/idea/src/org/jetbrains/kotlin/idea/intentions/MovePropertyToClassBodyIntention.kt +++ b/idea/src/org/jetbrains/kotlin/idea/intentions/MovePropertyToClassBodyIntention.kt @@ -29,7 +29,9 @@ import org.jetbrains.kotlin.resolve.lazy.BodyResolveMode class MovePropertyToClassBodyIntention : SelfTargetingIntention(KtParameter::class.java, "Move to class body") { - override fun isApplicableTo(element: KtParameter, caretOffset: Int): Boolean = element.isPropertyParameter() + override fun isApplicableTo(element: KtParameter, caretOffset: Int): Boolean { + return element.isPropertyParameter() && (element.ownerFunction as KtPrimaryConstructor).isNotContainedInAnnotation() + } override fun applyTo(element: KtParameter, editor: Editor?) { val parentClass = PsiTreeUtil.getParentOfType(element, KtClass::class.java) ?: return @@ -97,4 +99,6 @@ class MovePropertyToClassBodyIntention : SelfTargetingIntention(KtP nextSibling?.delete() // ':' symbol after use site delete() } + + fun KtPrimaryConstructor.isNotContainedInAnnotation() = !getContainingClassOrObject().isAnnotation() } diff --git a/idea/testData/quickfix/typeOfAnnotationMember/star.kt b/idea/testData/quickfix/typeOfAnnotationMember/star.kt index f6e3af3e085..344442f6428 100644 --- a/idea/testData/quickfix/typeOfAnnotationMember/star.kt +++ b/idea/testData/quickfix/typeOfAnnotationMember/star.kt @@ -1,5 +1,4 @@ // "Replace array of boxed with array of primitive" "false" -// ACTION: Move to class body // ERROR: Invalid type of annotation member annotation class SuperAnnotation( val foo: Array<*>, diff --git a/idea/testData/quickfix/typeOfAnnotationMember/string.kt b/idea/testData/quickfix/typeOfAnnotationMember/string.kt index 22580ecfe7a..e7e94db6bec 100644 --- a/idea/testData/quickfix/typeOfAnnotationMember/string.kt +++ b/idea/testData/quickfix/typeOfAnnotationMember/string.kt @@ -1,5 +1,4 @@ // "Replace array of boxed with array of primitive" "false" -// ACTION: Move to class body annotation class SuperAnnotation( val str: Array ) \ No newline at end of file