Use OverrideMemberChooserObject to generate also primary constructors
Relates to KT-27093 and similar problems
This commit is contained in:
+8
-1
@@ -216,6 +216,7 @@ private val ACTUAL_RENDERER = OVERRIDE_RENDERER.withOptions {
|
||||
secondaryConstructorsAsPrimary = false
|
||||
renderDefaultVisibility = false
|
||||
renderDefaultModality = false
|
||||
renderActualAnnotationPropertiesInPrimaryConstructor = true
|
||||
}
|
||||
|
||||
private fun PropertyDescriptor.wrap(forceOverride: Boolean): PropertyDescriptor {
|
||||
@@ -306,7 +307,13 @@ private fun generateFunction(
|
||||
val factory = KtPsiFactory(project)
|
||||
val functionText = renderer.render(newDescriptor) + body
|
||||
return when (descriptor) {
|
||||
is ClassConstructorDescriptor -> factory.createSecondaryConstructor(functionText)
|
||||
is ClassConstructorDescriptor -> {
|
||||
if (descriptor.isPrimary) {
|
||||
factory.createPrimaryConstructor(functionText)
|
||||
} else {
|
||||
factory.createSecondaryConstructor(functionText)
|
||||
}
|
||||
}
|
||||
else -> factory.createFunction(functionText)
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user