[PSI2IR] Fix parameter initialization for constructors with CR

This commit is contained in:
Anastasiya Shadrina
2021-10-29 05:19:14 +07:00
committed by TeamCityServer
parent 4caf42804a
commit 2fbfee3e11
20 changed files with 232 additions and 286 deletions
@@ -474,7 +474,7 @@ class ClassGenerator(
}
ktPrimaryConstructor.valueParameters.forEachIndexed { i, ktParameter ->
val irValueParameter = irPrimaryConstructor.valueParameters[i]
val irValueParameter = irPrimaryConstructor.valueParameters[i + ktClassOrObject.contextReceivers.size]
if (ktParameter.hasValOrVar()) {
val irProperty = PropertyGenerator(declarationGenerator)
.generatePropertyForPrimaryConstructorParameter(ktParameter, irValueParameter)
@@ -156,7 +156,8 @@ internal class InsertImplicitCasts(
return expression.transformPostfix {
transformReceiverArguments(substitutedDescriptor)
for (index in substitutedDescriptor.valueParameters.indices) {
val argument = getValueArgument(index) ?: continue
val irIndex = index + substitutedDescriptor.contextReceiverParameters.size
val argument = getValueArgument(irIndex) ?: continue
val parameterType = substitutedDescriptor.valueParameters[index].type
val originalParameterType = substitutedDescriptor.original.valueParameters[index].type
@@ -168,7 +169,7 @@ internal class InsertImplicitCasts(
else
parameterType
putValueArgument(index, argument.cast(expectedType, originalExpectedType = originalParameterType))
putValueArgument(irIndex, argument.cast(expectedType, originalExpectedType = originalParameterType))
}
}
}