IR: mostly remove descriptors from codegen

This commit is contained in:
Georgy Bronnikov
2019-04-15 01:29:55 +03:00
parent 9923d956aa
commit bfe148efd5
36 changed files with 1224 additions and 375 deletions
@@ -11,7 +11,6 @@ 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
import org.jetbrains.kotlin.ir.IrStatement
import org.jetbrains.kotlin.ir.UNDEFINED_OFFSET
import org.jetbrains.kotlin.ir.builders.*
import org.jetbrains.kotlin.ir.declarations.*
@@ -160,7 +159,7 @@ open class DefaultArgumentStubGenerator(
newIrFunction: IrFunction,
params: MutableList<IrVariable>
): IrExpression {
val dispatchCall = irCall(irFunction).apply {
val dispatchCall = irCall(irFunction.symbol).apply {
passTypeArgumentsFrom(newIrFunction)
dispatchReceiver = newIrFunction.dispatchReceiverParameter?.let { irGet(it) }
extensionReceiver = newIrFunction.extensionReceiverParameter?.let { irGet(it) }
@@ -11,9 +11,12 @@ import org.jetbrains.kotlin.descriptors.ClassKind
import org.jetbrains.kotlin.ir.declarations.IrClass
import org.jetbrains.kotlin.ir.declarations.IrDeclaration
import org.jetbrains.kotlin.ir.declarations.IrPackageFragment
import org.jetbrains.kotlin.ir.declarations.IrTypeParameter
import org.jetbrains.kotlin.ir.symbols.IrClassSymbol
import org.jetbrains.kotlin.ir.symbols.IrTypeParameterSymbol
import org.jetbrains.kotlin.ir.types.*
import org.jetbrains.kotlin.ir.types.impl.IrSimpleTypeImpl
import org.jetbrains.kotlin.ir.types.impl.makeTypeProjection
import org.jetbrains.kotlin.name.FqName
import org.jetbrains.kotlin.name.Name
import org.jetbrains.kotlin.utils.DFS
@@ -89,3 +92,30 @@ fun IrType.getPrimitiveArrayElementType() = (this as? IrSimpleType)?.let {
fun IrType.isNonPrimitiveArray() =
(this.isArray() || this.isNullableArray()) && !this.isPrimitiveArray()
fun IrType.substitute(params: List<IrTypeParameter>, arguments: List<IrType>): IrType =
substitute(params.map { it.symbol }.zip(arguments).toMap())
fun IrType.substitute(substitutionMap: Map<IrTypeParameterSymbol, IrType>): IrType {
if (this !is IrSimpleType) return this
substitutionMap[classifier]?.let { return it }
val newArguments = arguments.map {
if (it is IrTypeProjection) {
makeTypeProjection(it.type.substitute(substitutionMap), it.variance)
} else {
it
}
}
val newAnnotations = annotations.map { it.deepCopyWithSymbols() }
return IrSimpleTypeImpl(
classifier,
hasQuestionMark,
newArguments,
newAnnotations
)
}