[kotlin] Change signature: refactoring makes abstract property in interface internal
authorAlexander Danilov <alexander.danilov@jetbrains.com>
Fri, 30 Sep 2022 19:09:11 +0000 (21:09 +0200)
committerintellij-monorepo-bot <intellij-monorepo-bot-no-reply@jetbrains.com>
Sat, 1 Oct 2022 00:08:04 +0000 (00:08 +0000)
Set original visibility of property if it cannot be changed

^KTIJ-6091 fixed

GitOrigin-RevId: c543fc886b58894081f84917f442edd921cb1ed4

plugins/kotlin/idea/src/org/jetbrains/kotlin/idea/refactoring/changeSignature/ui/KotlinChangePropertySignatureDialog.kt

index b394ca265f509e381cddb66c36333586374fa0ff..4b9fa742ffa320bb0f87bc4dcf1a50c438d32781 100644 (file)
@@ -133,7 +133,7 @@ class KotlinChangePropertySignatureDialog(
 
     private fun calculateSignature(): String = buildString {
         methodDescriptor.baseDeclaration.safeAs<KtValVarKeywordOwner>()?.valOrVarKeyword?.let {
-            val visibility = visibilityCombo.selectedItem
+            val visibility = if (methodDescriptor.canChangeVisibility()) visibilityCombo.selectedItem else methodDescriptor.visibility
             if (visibility != DescriptorVisibilities.DEFAULT_VISIBILITY) {
                 append("$visibility ")
             }
@@ -238,7 +238,7 @@ class KotlinChangePropertySignatureDialog(
             originalDescriptor,
             name,
             returnTypeCodeFragment.getTypeInfo(isCovariant = false, forPreview = false),
-            visibilityCombo.selectedItem as DescriptorVisibility,
+            if (methodDescriptor.canChangeVisibility()) visibilityCombo.selectedItem as DescriptorVisibility else methodDescriptor.visibility,
             emptyList(),
             receiver,
             originalDescriptor.method,