IR fixes to help symbolization of K/N

This commit is contained in:
Igor Chevdar
2018-11-21 17:08:21 +03:00
parent d363763420
commit a78b80f8bf
5 changed files with 49 additions and 72 deletions
@@ -14,6 +14,7 @@ import org.jetbrains.kotlin.ir.expressions.impl.*
import org.jetbrains.kotlin.ir.symbols.*
import org.jetbrains.kotlin.ir.types.IrType
import org.jetbrains.kotlin.ir.types.classifierOrFail
import org.jetbrains.kotlin.ir.util.parentAsClass
import org.jetbrains.kotlin.types.KotlinType
import org.jetbrains.kotlin.utils.addToStdlib.assertedCast
@@ -218,7 +219,8 @@ fun IrBuilderWithScope.irCall(callee: IrFunction, origin: IrStatementOrigin): Ir
IrCallImpl(startOffset, endOffset, callee.returnType, callee.symbol, callee.descriptor, origin)
fun IrBuilderWithScope.irDelegatingConstructorCall(callee: IrConstructor): IrDelegatingConstructorCall =
IrDelegatingConstructorCallImpl(startOffset, endOffset, callee.returnType, callee.symbol, callee.descriptor, callee.typeParameters.size)
IrDelegatingConstructorCallImpl(startOffset, endOffset, callee.returnType, callee.symbol, callee.descriptor,
callee.parentAsClass.typeParameters.size, callee.valueParameters.size)
fun IrBuilderWithScope.irCallOp(
callee: IrFunctionSymbol,
@@ -50,6 +50,13 @@ class IrDelegatingConstructorCallImpl(
descriptor: ClassConstructorDescriptor
) : this(startOffset, endOffset, type, symbol, descriptor, descriptor.typeParametersCount, descriptor.valueParameters.size)
constructor(
startOffset: Int,
endOffset: Int,
type: IrType,
symbol: IrConstructorSymbol
) : this(startOffset, endOffset, type, symbol, symbol.descriptor)
constructor(
startOffset: Int,
endOffset: Int,
@@ -442,21 +442,6 @@ fun createField(
return IrFieldImpl(startOffset, endOffset, origin, descriptor, type)
}
fun IrFunction.createDispatchReceiverParameter() {
assert(this.dispatchReceiverParameter == null)
val descriptor = this.descriptor.dispatchReceiverParameter ?: return
this.dispatchReceiverParameter = IrValueParameterImpl(
startOffset,
endOffset,
IrDeclarationOrigin.DEFINED,
descriptor,
this.parentAsClass.defaultType,
null
).also { it.parent = this }
}
// In presence of `IrBlock`s, return the expression that actually serves as the value (the last one).
tailrec fun IrExpression.removeBlocks(): IrExpression? = when (this) {
is IrBlock -> (statements.last() as? IrExpression)?.removeBlocks()