Fix parameter indices on lowering
This commit is contained in:
+6
-6
@@ -109,20 +109,20 @@ internal fun createStaticFunctionWithReceivers(owner: ClassOrPackageFragmentDesc
|
||||
name,
|
||||
CallableMemberDescriptor.Kind.DECLARATION, descriptor.source
|
||||
)
|
||||
|
||||
var offset = 0
|
||||
val dispatchReceiver =
|
||||
ValueParameterDescriptorImpl.createWithDestructuringDeclarations(
|
||||
newFunction, null, 0, AnnotationsImpl(emptyList()), Name.identifier("this"),
|
||||
newFunction, null, offset++, AnnotationsImpl(emptyList()), Name.identifier("this"),
|
||||
dispatchReceiverType, false, false, false, null, descriptor.source, null)
|
||||
val extensionReceiver =
|
||||
descriptor.extensionReceiverParameter?.let { extensionReceiver ->
|
||||
ValueParameterDescriptorImpl.createWithDestructuringDeclarations(
|
||||
newFunction, null, 1, AnnotationsImpl(emptyList()), Name.identifier("receiver"),
|
||||
newFunction, null, offset++, AnnotationsImpl(emptyList()), Name.identifier("receiver"),
|
||||
extensionReceiver.value.type, false, false, false, null, extensionReceiver.source, null)
|
||||
}
|
||||
|
||||
val valueParameters = listOf(dispatchReceiver, extensionReceiver).filterNotNull() +
|
||||
descriptor.valueParameters.map { it.copy(newFunction, it.name, it.index + 1) }
|
||||
val valueParameters = listOfNotNull(dispatchReceiver, extensionReceiver) +
|
||||
descriptor.valueParameters.map { it.copy(newFunction, it.name, it.index + offset) }
|
||||
|
||||
newFunction.initialize(
|
||||
null, null, emptyList()/*TODO: type parameters*/,
|
||||
@@ -135,7 +135,7 @@ internal fun FunctionDescriptor.createFunctionAndMapVariables(oldFunction: IrFun
|
||||
IrFunctionImpl(oldFunction.startOffset, oldFunction.endOffset, oldFunction.origin, this, oldFunction.body).also {
|
||||
val mapping: Map<ValueDescriptor, ValueDescriptor> =
|
||||
(
|
||||
listOf(oldFunction.descriptor.dispatchReceiverParameter!!, oldFunction.descriptor.extensionReceiverParameter).filterNotNull() +
|
||||
listOfNotNull(oldFunction.descriptor.dispatchReceiverParameter!!, oldFunction.descriptor.extensionReceiverParameter) +
|
||||
oldFunction.descriptor.valueParameters
|
||||
).zip(this.valueParameters).toMap()
|
||||
|
||||
|
||||
+5
-7
@@ -34,22 +34,20 @@ fun FunctionDescriptor.toStatic(
|
||||
)
|
||||
|
||||
var offset = 0
|
||||
val dispatchReceiver = this.dispatchReceiverParameter?.let {
|
||||
offset++
|
||||
val dispatchReceiver = dispatchReceiverParameter?.let {
|
||||
ValueParameterDescriptorImpl.createWithDestructuringDeclarations(
|
||||
newFunction, null, 0, AnnotationsImpl(emptyList()), Name.identifier("this"),
|
||||
newFunction, null, offset++, AnnotationsImpl(emptyList()), Name.identifier("this"),
|
||||
dispatchReceiverClass!!.defaultType, false, false, false, null, dispatchReceiverClass.source, null)
|
||||
}
|
||||
|
||||
val extensionReceiver = extensionReceiverParameter?.let {
|
||||
offset++
|
||||
ValueParameterDescriptorImpl.createWithDestructuringDeclarations(
|
||||
newFunction, null, 1, AnnotationsImpl(emptyList()), Name.identifier("receiver"),
|
||||
newFunction, null, offset++, AnnotationsImpl(emptyList()), Name.identifier("receiver"),
|
||||
it.value.type, false, false, false, null, it.source, null)
|
||||
}
|
||||
|
||||
val valueParameters = listOf(dispatchReceiver, extensionReceiver).filterNotNull() +
|
||||
valueParameters.map { it.copy(newFunction, it.name, it.index + offset) }
|
||||
val valueParameters = listOfNotNull(dispatchReceiver, extensionReceiver) +
|
||||
valueParameters.map { it.copy(newFunction, it.name, it.index + offset) }
|
||||
|
||||
newFunction.initialize(
|
||||
null, null, emptyList()/*TODO: type parameters*/,
|
||||
|
||||
Reference in New Issue
Block a user