Convert to primary constructor preserves accessors #KT-17996 Fixed

This commit is contained in:
Dmitry Neverov
2017-05-29 07:34:09 +03:00
committed by Mikhail Glukhikh
parent 4346fb5c23
commit b206f6288d
6 changed files with 65 additions and 1 deletions
@@ -128,7 +128,9 @@ class ConvertSecondaryConstructorToPrimaryIntention : SelfTargetingRangeIntentio
if (parameterDescriptor != null && propertyDescriptor != null) {
val property = DescriptorToSourceUtils.descriptorToDeclaration(propertyDescriptor) as? KtProperty
if (property != null) {
if (propertyDescriptor.name == parameterDescriptor.name && propertyDescriptor.type == parameterDescriptor.type) {
if (propertyDescriptor.name == parameterDescriptor.name &&
propertyDescriptor.type == parameterDescriptor.type &&
propertyDescriptor.accessors.all { it.isDefault }) {
propertyCommentSaver = CommentSaver(property)
val valOrVar = if (property.isVar) factory.createVarKeyword() else factory.createValKeyword()
newParameter.addBefore(valOrVar, newParameter.nameIdentifier)