Support handler parameter generation

This commit is contained in:
Mikhael Bogdanov
2017-06-08 14:05:50 +02:00
committed by Svyatoslav Scherbina
parent cd54f010e0
commit f6d47aa93c
2 changed files with 9 additions and 1 deletions
@@ -16,9 +16,11 @@ import org.jetbrains.kotlin.util.OperatorNameConventions
// This is what Context collects about IR.
abstract class Ir<out T: CommonBackendContext>(val context: T, val irModule: IrModuleFragment) {
abstract val symbols: Symbols<T>
val defaultParameterDeclarationsCache = mutableMapOf<FunctionDescriptor, IrFunction>()
abstract val symbols: Symbols<T>
open fun shouldGenerateHandlerParameterForDefaultBodyFun() = false
}
open class Symbols<out T: CommonBackendContext>(val context: T, private val symbolTable: SymbolTable) {
@@ -368,6 +368,12 @@ private fun FunctionDescriptor.generateDefaultsFunction(context: CommonBackendCo
kConstructorMarkerName,
context.ir.symbols.defaultConstructorMarker.owner.defaultType)
}
else if (context.ir.shouldGenerateHandlerParameterForDefaultBodyFun()) {
syntheticParameters += valueParameter(descriptor, syntheticParameters.last().index + 1,
"handler".synthesizedName,
context.ir.symbols.any.owner.defaultType)
}
descriptor.initialize(
/* receiverParameterType = */ extensionReceiverParameter?.type,
/* dispatchReceiverParameter = */ dispatchReceiverParameter,