Nabil
09/23/2020, 7:21 PMaddGetter
extension was left on the IrProperty
https://github.com/JetBrains/kotlin/blob/master/compiler/ir/backend.common/src/org/jetbrains/kotlin/ir/builders/declarations/declarationBuilders.kt#L107 while addSetter
was removed in https://github.com/JetBrains/kotlin/commit/d1dc938a5d7331ba43fcbb8ce53c3e17ef76a22a#diff-2726c3747ace0a1c93ad82365cf3ff18L114 ? What's the new way to create setters on a generated property since 1.4.255
?Nabil
09/24/2020, 9:51 AMinline fun IrProperty.addSetter(builder: IrFunctionBuilder.() -> Unit = {}): IrSimpleFunction =
IrFunctionBuilder().run {
factory.buildFun {
this.name = Name.special("<set-${this@addSetter.name}>")
builder()
}.also {
setter ->
this@addSetter.setter = setter
setter.correspondingPropertySymbol = this@addSetter.symbol
setter.parent = this@addSetter.parent
}
}
Then call it on a property like
val setter = property.addSetter() {
visibility = DescriptorVisibilities.PUBLIC
modality = Modality.FINAL
returnType = pluginContext.irBuiltIns.unitType
origin = IrDeclarationOrigin.DEFAULT_PROPERTY_ACCESSOR
}
still wondering though why it was removed?