[IR] Make IrFunctionSymbol a sealed interface

This commit is contained in:
Sergej Jaskiewicz
2023-05-05 13:45:40 +02:00
committed by Space Team
parent d0ca89f0a0
commit 6c211f3a39
9 changed files with 5 additions and 13 deletions
@@ -308,8 +308,6 @@ internal class AdapterGenerator(
origin = null,
superQualifierSymbol = null
)
else ->
error("unknown callee kind: ${adapteeFunction.render()}")
}
var adapterParameterIndex = 0
@@ -13,6 +13,7 @@ import org.jetbrains.kotlin.ir.declarations.*
import org.jetbrains.kotlin.ir.expressions.*
import org.jetbrains.kotlin.ir.expressions.impl.*
import org.jetbrains.kotlin.ir.symbols.IrConstructorSymbol
import org.jetbrains.kotlin.ir.symbols.IrSimpleFunctionSymbol
import org.jetbrains.kotlin.ir.symbols.IrValueParameterSymbol
import org.jetbrains.kotlin.ir.symbols.IrValueSymbol
import org.jetbrains.kotlin.ir.types.classOrNull
@@ -261,10 +262,9 @@ class InnerClassConstructorCallsLowering(val context: BackendContext, val innerC
val newCallee = innerClassesSupport.getInnerClassConstructorWithOuterThisParameter(callee.owner)
val newReflectionTarget = expression.reflectionTarget?.let { reflectionTarget ->
if (reflectionTarget is IrConstructorSymbol) {
innerClassesSupport.getInnerClassConstructorWithOuterThisParameter(reflectionTarget.owner)
} else {
null
when (reflectionTarget) {
is IrConstructorSymbol -> innerClassesSupport.getInnerClassConstructorWithOuterThisParameter(reflectionTarget.owner)
is IrSimpleFunctionSymbol -> null
}
}
@@ -115,7 +115,6 @@ class CachedSyntheticDeclarations(private val context: JvmBackendContext) {
symbol.owner.makeConstructorAccessor().symbol
is IrSimpleFunctionSymbol ->
symbol.owner.makeSimpleFunctionAccessor(superQualifierSymbol, dispatchReceiverType, parent, scopes).symbol
else -> error("Unknown subclass of IrFunctionSymbol")
}
}
}
@@ -313,7 +313,6 @@ internal class ReflectionReferencesGenerator(statementGenerator: StatementGenera
IrConstructorCallImpl.fromSymbolDescriptor(startOffset, endOffset, irType, adapteeSymbol)
is IrSimpleFunctionSymbol ->
IrCallImpl.fromSymbolDescriptor(startOffset, endOffset, irType, adapteeSymbol)
else -> error("Unknown symbol kind $adapteeSymbol")
}
val hasBoundDispatchReceiver = resolvedCall.dispatchReceiver != null && resolvedCall.dispatchReceiver !is TransientReceiver
@@ -272,7 +272,6 @@ fun IrBuilderWithScope.irCall(callee: IrFunctionSymbol, type: IrType): IrFunctio
when (callee) {
is IrConstructorSymbol -> irCall(callee, type)
is IrSimpleFunctionSymbol -> irCall(callee, type)
else -> throw AssertionError("Unexpected callee: $callee")
}
fun IrBuilderWithScope.irCall(callee: IrSimpleFunctionSymbol): IrCall =
@@ -98,7 +98,7 @@ interface IrReturnTargetSymbol : IrSymbol {
override val owner: IrReturnTarget
}
interface IrFunctionSymbol : IrReturnTargetSymbol {
sealed interface IrFunctionSymbol : IrReturnTargetSymbol {
override val owner: IrFunction
}
@@ -219,7 +219,6 @@ open class DeepCopySymbolRemapper(
when (symbol) {
is IrSimpleFunctionSymbol -> functions.getReferenced(symbol)
is IrConstructorSymbol -> constructors.getReferenced(symbol)
else -> throw IllegalArgumentException("Unexpected symbol $symbol")
}
override fun getReferencedReturnableBlock(symbol: IrReturnableBlockSymbol): IrReturnableBlockSymbol =
@@ -708,7 +708,6 @@ internal class PartiallyLinkedIrTreePatcher(
val expectedDispatchReceiverClassifier: IrClassSymbol = when (symbol) {
is IrSimpleFunctionSymbol -> function.parent as? IrClass
is IrConstructorSymbol -> (function.parent as? IrClass)?.takeIf { it.isInner }?.parent as? IrClass
else -> null
}?.symbol ?: return@run false
val referenceType: IrSimpleType = type as? IrSimpleType ?: return@run false
@@ -130,7 +130,6 @@ internal class ExpectToActualDefaultValueCopier(private val irModule: IrModuleFr
override fun getReferencedFunction(symbol: IrFunctionSymbol): IrFunctionSymbol = when (symbol) {
is IrSimpleFunctionSymbol -> getReferencedSimpleFunction(symbol)
is IrConstructorSymbol -> getReferencedConstructor(symbol)
else -> error("Unexpected symbol $symbol ${symbol.descriptor}")
}
override fun getReferencedSimpleFunction(symbol: IrSimpleFunctionSymbol) = when {