diff --git a/idea/src/org/jetbrains/kotlin/idea/quickfix/MakeConstructorParameterPropertyFix.kt b/idea/src/org/jetbrains/kotlin/idea/quickfix/MakeConstructorParameterPropertyFix.kt index 2f022719d0b..4d1f1ea47e3 100644 --- a/idea/src/org/jetbrains/kotlin/idea/quickfix/MakeConstructorParameterPropertyFix.kt +++ b/idea/src/org/jetbrains/kotlin/idea/quickfix/MakeConstructorParameterPropertyFix.kt @@ -23,6 +23,7 @@ import com.intellij.psi.PsiFile import org.jetbrains.kotlin.diagnostics.Diagnostic import org.jetbrains.kotlin.diagnostics.Errors import org.jetbrains.kotlin.idea.refactoring.changeSignature.KotlinValVar +import org.jetbrains.kotlin.lexer.KtTokens import org.jetbrains.kotlin.psi.KtFile import org.jetbrains.kotlin.psi.KtNameReferenceExpression import org.jetbrains.kotlin.psi.KtParameter @@ -45,6 +46,7 @@ class MakeConstructorParameterPropertyFix( override fun invoke(project: Project, editor: Editor?, file: KtFile) { element.addBefore(kotlinValVar.createKeyword(KtPsiFactory(project))!!, element.firstChild) + element.addModifier(KtTokens.PRIVATE_KEYWORD) } companion object Factory : KotlinIntentionActionsFactory() { diff --git a/idea/testData/quickfix/makeConstructorParameterProperty/inner.kt.after b/idea/testData/quickfix/makeConstructorParameterProperty/inner.kt.after index 398d372bdfd..3ec5c7d39eb 100644 --- a/idea/testData/quickfix/makeConstructorParameterProperty/inner.kt.after +++ b/idea/testData/quickfix/makeConstructorParameterProperty/inner.kt.after @@ -1,6 +1,6 @@ // "Make primary constructor parameter 'bar' a property in class 'B'" "true" -class B(val bar: String) { +class B(private val bar: String) { inner class A { fun foo() { diff --git a/idea/testData/quickfix/makeConstructorParameterProperty/val.kt.after b/idea/testData/quickfix/makeConstructorParameterProperty/val.kt.after index fb8e6431a8d..5fdd9071d09 100644 --- a/idea/testData/quickfix/makeConstructorParameterProperty/val.kt.after +++ b/idea/testData/quickfix/makeConstructorParameterProperty/val.kt.after @@ -1,6 +1,6 @@ // "Make primary constructor parameter 'foo' a property" "true" -class A(val foo: String) { +class A(private val foo: String) { fun bar() { val a = foo } diff --git a/idea/testData/quickfix/makeConstructorParameterProperty/var.kt.after b/idea/testData/quickfix/makeConstructorParameterProperty/var.kt.after index 6450fa71612..c1781aa27cf 100644 --- a/idea/testData/quickfix/makeConstructorParameterProperty/var.kt.after +++ b/idea/testData/quickfix/makeConstructorParameterProperty/var.kt.after @@ -1,6 +1,6 @@ // "Make primary constructor parameter 'foo' a property" "true" -class A(var foo: String) { +class A(private var foo: String) { fun bar() { foo = "" }