IR: remove non-supertype usages of abstract impl classes

Work with the corresponding base interfaces instead. This change will
help in moving the IR element hierarchy from interfaces to classes,
should the need arise.

There's a possible change in behavior in
`CallAndReferenceGenerator.applyCallArguments`, which however doesn't
seem to break anything: IrPropertyReferenceImpl can now also be handled
by this method.
This commit is contained in:
Alexander Udalov
2020-06-23 15:18:33 +02:00
parent ccac23f5b2
commit d794c9dc4d
11 changed files with 45 additions and 47 deletions
@@ -120,7 +120,7 @@ abstract class IrFileDeserializer(
abstract fun deserializeString(index: Int): String
abstract fun deserializeExpressionBody(index: Int): IrExpression
abstract fun deserializeStatementBody(index: Int): IrElement
abstract fun deserializeLoopHeader(loopIndex: Int, loopBuilder: () -> IrLoopBase): IrLoopBase
abstract fun deserializeLoopHeader(loopIndex: Int, loopBuilder: () -> IrLoop): IrLoop
abstract fun referenceIrSymbol(symbol: IrSymbol, signature: IdSignature)
@@ -709,7 +709,7 @@ abstract class IrFileDeserializer(
return IrWhenImpl(start, end, type, origin, branches)
}
private fun deserializeLoop(proto: ProtoLoop, loop: IrLoopBase): IrLoopBase {
private fun deserializeLoop(proto: ProtoLoop, loop: IrLoop): IrLoop {
val label = if (proto.hasLabel()) deserializeString(proto.label) else null
val body = if (proto.hasBody()) deserializeExpression(proto.body) else null
val condition = deserializeExpression(proto.condition)
@@ -21,9 +21,9 @@ import org.jetbrains.kotlin.ir.declarations.impl.IrFileImpl
import org.jetbrains.kotlin.ir.declarations.impl.IrModuleFragmentImpl
import org.jetbrains.kotlin.ir.descriptors.*
import org.jetbrains.kotlin.ir.expressions.IrExpression
import org.jetbrains.kotlin.ir.expressions.IrLoop
import org.jetbrains.kotlin.ir.expressions.impl.IrBlockBodyImpl
import org.jetbrains.kotlin.ir.expressions.impl.IrErrorExpressionImpl
import org.jetbrains.kotlin.ir.expressions.impl.IrLoopBase
import org.jetbrains.kotlin.ir.linkage.IrDeserializer
import org.jetbrains.kotlin.ir.symbols.*
import org.jetbrains.kotlin.ir.symbols.impl.*
@@ -230,7 +230,7 @@ abstract class KotlinIrLinker(
private val moduleDeserializer: IrModuleDeserializer
) : IrFileDeserializer(logger, builtIns, symbolTable, !onlyHeaders, deserializeFakeOverrides) {
private var fileLoops = mutableMapOf<Int, IrLoopBase>()
private var fileLoops = mutableMapOf<Int, IrLoop>()
lateinit var file: IrFile
@@ -396,7 +396,7 @@ abstract class KotlinIrLinker(
override fun deserializeString(index: Int): String =
loadStringProto(index)
override fun deserializeLoopHeader(loopIndex: Int, loopBuilder: () -> IrLoopBase) =
override fun deserializeLoopHeader(loopIndex: Int, loopBuilder: () -> IrLoop) =
fileLoops.getOrPut(loopIndex, loopBuilder)
override fun deserializeExpressionBody(index: Int): IrExpression {
@@ -688,4 +688,4 @@ enum class DeserializationStrategy(
EXPLICITLY_EXPORTED(true, true, false, true),
ONLY_DECLARATION_HEADERS(false, false, false, false),
WITH_INLINE_BODIES(false, false, false, true)
}
}