Do not create new descriptors for "call" instructions. Calls for functions declared in inlineBody will be substituted in second pass
This commit is contained in:
committed by
KonstantinAnisimov
parent
42955526bf
commit
5920e0d8ba
+7
-29
@@ -146,27 +146,6 @@ internal class DeepCopyIrTreeWithDescriptors(val targetDescriptor: DeclarationDe
|
|||||||
super.visitVariable(declaration)
|
super.visitVariable(declaration)
|
||||||
}
|
}
|
||||||
|
|
||||||
//---------------------------------------------------------------------//
|
|
||||||
|
|
||||||
override fun visitCall(expression: IrCall) {
|
|
||||||
|
|
||||||
val oldDescriptor = expression.descriptor as FunctionDescriptor
|
|
||||||
if (oldDescriptor is SimpleFunctionDescriptor) {
|
|
||||||
val newContainingDeclaration = descriptorSubstituteMap.getOrDefault(oldDescriptor, oldDescriptor)
|
|
||||||
val newReturnType = substituteType(oldDescriptor.returnType)!!
|
|
||||||
val newValueParameters = copyValueParameters(oldDescriptor.valueParameters, newContainingDeclaration as CallableDescriptor)
|
|
||||||
val newDescriptor = oldDescriptor
|
|
||||||
.newCopyBuilder()
|
|
||||||
.setReturnType(newReturnType)
|
|
||||||
.setValueParameters(newValueParameters)
|
|
||||||
.setOriginal(oldDescriptor.original)
|
|
||||||
.build()
|
|
||||||
descriptorSubstituteMap[oldDescriptor] = newDescriptor!!
|
|
||||||
}
|
|
||||||
|
|
||||||
super.visitCall(expression)
|
|
||||||
}
|
|
||||||
|
|
||||||
//--- Copy descriptors ------------------------------------------------//
|
//--- Copy descriptors ------------------------------------------------//
|
||||||
|
|
||||||
private fun generateCopyName(name: Name): Name {
|
private fun generateCopyName(name: Name): Name {
|
||||||
@@ -203,10 +182,10 @@ internal class DeepCopyIrTreeWithDescriptors(val targetDescriptor: DeclarationDe
|
|||||||
|
|
||||||
val oldDispatchReceiverParameter = oldDescriptor.dispatchReceiverParameter
|
val oldDispatchReceiverParameter = oldDescriptor.dispatchReceiverParameter
|
||||||
val newDispatchReceiverParameter = oldDispatchReceiverParameter?.let { descriptorSubstituteMap.getOrDefault(it, it) as ReceiverParameterDescriptor }
|
val newDispatchReceiverParameter = oldDispatchReceiverParameter?.let { descriptorSubstituteMap.getOrDefault(it, it) as ReceiverParameterDescriptor }
|
||||||
val newTypeParameters = oldDescriptor.typeParameters // TODO substitute types
|
val newTypeParameters = oldDescriptor.typeParameters // TODO substitute types
|
||||||
val newValueParameters = copyValueParameters(oldDescriptor.valueParameters, this)
|
val newValueParameters = copyValueParameters(oldDescriptor.valueParameters, this)
|
||||||
val newReceiverParameterType = substituteType(oldDescriptor.extensionReceiverParameter?.type)
|
val newReceiverParameterType = substituteType(oldDescriptor.extensionReceiverParameter?.type)
|
||||||
val newReturnType = substituteType(oldDescriptor.returnType)
|
val newReturnType = substituteType(oldDescriptor.returnType)
|
||||||
|
|
||||||
initialize(
|
initialize(
|
||||||
/* receiverParameterType = */ newReceiverParameterType,
|
/* receiverParameterType = */ newReceiverParameterType,
|
||||||
@@ -235,11 +214,10 @@ internal class DeepCopyIrTreeWithDescriptors(val targetDescriptor: DeclarationDe
|
|||||||
/* source = */ oldDescriptor.source
|
/* source = */ oldDescriptor.source
|
||||||
).apply {
|
).apply {
|
||||||
|
|
||||||
val newTypeParameters = oldDescriptor.typeParameters
|
val newTypeParameters = oldDescriptor.typeParameters
|
||||||
val newValueParameters = copyValueParameters(oldDescriptor.valueParameters, this)
|
val newValueParameters = copyValueParameters(oldDescriptor.valueParameters, this)
|
||||||
val receiverParameterType = substituteType(oldDescriptor.dispatchReceiverParameter?.type)
|
val receiverParameterType = substituteType(oldDescriptor.dispatchReceiverParameter?.type)
|
||||||
val returnType = substituteType(oldDescriptor.returnType)
|
val returnType = substituteType(oldDescriptor.returnType)
|
||||||
assert(newTypeParameters.isEmpty())
|
|
||||||
|
|
||||||
initialize(
|
initialize(
|
||||||
/* receiverParameterType = */ receiverParameterType,
|
/* receiverParameterType = */ receiverParameterType,
|
||||||
|
|||||||
Reference in New Issue
Block a user