IR: Fixed bug with dispatch receiver parameter

When building dispatch receiver for newly created functions
take ReceiverParameter from the parent class rather than create new
This commit is contained in:
Igor Chevdar
2019-01-14 18:42:18 +03:00
parent 22f77134b0
commit 6220291ef8
@@ -211,21 +211,18 @@ fun IrClass.createParameterDeclarations() {
fun IrFunction.createDispatchReceiverParameter(origin: IrDeclarationOrigin? = null) {
assert(dispatchReceiverParameter == null)
dispatchReceiverParameter = WrappedReceiverParameterDescriptor().let {
IrValueParameterImpl(
startOffset, endOffset,
origin ?: parentAsClass.origin,
IrValueParameterSymbolImpl(it),
Name.special("<this>"),
0,
parentAsClass.defaultType,
null,
false,
false
).apply {
it.bind(this)
parent = this@createDispatchReceiverParameter
}
dispatchReceiverParameter = IrValueParameterImpl(
startOffset, endOffset,
origin ?: parentAsClass.origin,
IrValueParameterSymbolImpl(parentAsClass.thisReceiver!!.descriptor),
Name.special("<this>"),
0,
parentAsClass.defaultType,
null,
false,
false
).apply {
parent = this@createDispatchReceiverParameter
}
}