JVM_IR: correct some type parameter bugs
This commit is contained in:
@@ -153,6 +153,7 @@ fun IrValueParameter.copyTo(
|
||||
descriptor.bind(it)
|
||||
it.parent = irFunction
|
||||
it.defaultValue = defaultValueCopy
|
||||
it.annotations.addAll(annotations.map { it.deepCopyWithSymbols() })
|
||||
}
|
||||
}
|
||||
|
||||
@@ -252,6 +253,12 @@ fun IrFunction.copyValueParametersToStatic(
|
||||
}
|
||||
}
|
||||
|
||||
fun IrFunctionAccessExpression.passTypeArgumentsFrom(irFunction: IrTypeParametersContainer, offset: Int = 0) {
|
||||
irFunction.typeParameters.forEachIndexed { i, param ->
|
||||
putTypeArgument(i + offset, param.defaultType)
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
Type parameters should correspond to the function where they are defined.
|
||||
`source` is where the type is originally taken from.
|
||||
@@ -463,4 +470,7 @@ fun IrClass.addFakeOverrides() {
|
||||
.toMutableMap()
|
||||
|
||||
declarations += fakeOverriddenFunctions.values
|
||||
}
|
||||
}
|
||||
|
||||
fun IrValueParameter.isInlineParameter() =
|
||||
!isNoinline && !type.isNullable() && type.isFunctionOrKFunction()
|
||||
+5
-10
@@ -7,9 +7,7 @@ package org.jetbrains.kotlin.backend.common.lower
|
||||
|
||||
import org.jetbrains.kotlin.backend.common.*
|
||||
import org.jetbrains.kotlin.backend.common.descriptors.*
|
||||
import org.jetbrains.kotlin.backend.common.ir.copyTo
|
||||
import org.jetbrains.kotlin.backend.common.ir.copyTypeParametersFrom
|
||||
import org.jetbrains.kotlin.backend.common.ir.ir2string
|
||||
import org.jetbrains.kotlin.backend.common.ir.*
|
||||
import org.jetbrains.kotlin.backend.common.phaser.makeIrFilePhase
|
||||
import org.jetbrains.kotlin.descriptors.Modality
|
||||
import org.jetbrains.kotlin.ir.IrElement
|
||||
@@ -136,11 +134,10 @@ open class DefaultArgumentStubGenerator(
|
||||
endOffset = irFunction.endOffset,
|
||||
type = context.irBuiltIns.unitType,
|
||||
symbol = irFunction.symbol, descriptor = irFunction.symbol.descriptor,
|
||||
typeArgumentsCount = irFunction.typeParameters.size
|
||||
typeArgumentsCount = newIrFunction.parentAsClass.typeParameters.size + newIrFunction.typeParameters.size
|
||||
).apply {
|
||||
newIrFunction.typeParameters.forEachIndexed { i, param ->
|
||||
putTypeArgument(i, param.defaultType)
|
||||
}
|
||||
passTypeArgumentsFrom(newIrFunction.parentAsClass)
|
||||
passTypeArgumentsFrom(newIrFunction)
|
||||
dispatchReceiver = newIrFunction.dispatchReceiverParameter?.let { irGet(it) }
|
||||
|
||||
params.forEachIndexed { i, variable -> putValueArgument(i, irGet(variable)) }
|
||||
@@ -164,9 +161,7 @@ open class DefaultArgumentStubGenerator(
|
||||
params: MutableList<IrVariable>
|
||||
): IrExpression {
|
||||
val dispatchCall = irCall(irFunction).apply {
|
||||
newIrFunction.typeParameters.forEachIndexed { i, param ->
|
||||
putTypeArgument(i, param.defaultType)
|
||||
}
|
||||
passTypeArgumentsFrom(newIrFunction)
|
||||
dispatchReceiver = newIrFunction.dispatchReceiverParameter?.let { irGet(it) }
|
||||
extensionReceiver = newIrFunction.extensionReceiverParameter?.let { irGet(it) }
|
||||
|
||||
|
||||
+2
-1
@@ -148,6 +148,7 @@ class InnerClassConstructorCallsLowering(val context: BackendContext) : BodyLowe
|
||||
expression.startOffset, expression.endOffset, expression.type, newCallee.symbol, expression.origin
|
||||
)
|
||||
|
||||
newCall.copyTypeArgumentsFrom(expression)
|
||||
newCall.putValueArgument(0, dispatchReceiver)
|
||||
for (i in 1..newCallee.valueParameters.lastIndex) {
|
||||
newCall.putValueArgument(i, expression.getValueArgument(i - 1))
|
||||
@@ -166,7 +167,7 @@ class InnerClassConstructorCallsLowering(val context: BackendContext) : BodyLowe
|
||||
val newCallee = context.declarationFactory.getInnerClassConstructorWithOuterThisParameter(classConstructor)
|
||||
val newCall = IrDelegatingConstructorCallImpl(
|
||||
expression.startOffset, expression.endOffset, context.irBuiltIns.unitType, newCallee.symbol, newCallee.descriptor,
|
||||
classConstructor.typeParameters.size
|
||||
expression.typeArgumentsCount
|
||||
).apply { copyTypeArgumentsFrom(expression) }
|
||||
|
||||
newCall.putValueArgument(0, dispatchReceiver)
|
||||
|
||||
Reference in New Issue
Block a user