Support IR API changes

(cherry picked from commit bcd76103c627cca0b654d295c0e0fbc1542caf41)
This commit is contained in:
Anton Bannykh
2020-01-24 12:51:20 +03:00
committed by Vasily Levchenko
parent 8bcee1e632
commit 585f4ae9ee
13 changed files with 24 additions and 22 deletions
@@ -76,7 +76,7 @@ internal val Context.getBoxFunction: (IrClass) -> IrSimpleFunction by Context.la
isFakeOverride = false,
isOperator = false
).also { function ->
function.valueParameters.add(WrappedValueParameterDescriptor().let {
function.valueParameters = listOf(WrappedValueParameterDescriptor().let {
IrValueParameterImpl(
startOffset, endOffset,
IrDeclarationOrigin.DEFINED,
@@ -130,7 +130,7 @@ internal val Context.getUnboxFunction: (IrClass) -> IrSimpleFunction by Context.
isFakeOverride = false,
isOperator = false
).also { function ->
function.valueParameters.add(WrappedValueParameterDescriptor().let {
function.valueParameters = listOf(WrappedValueParameterDescriptor().let {
IrValueParameterImpl(
startOffset, endOffset,
IrDeclarationOrigin.DEFINED,
@@ -126,7 +126,7 @@ internal class BuiltInFictitiousFunctionIrClassFactory(
builtClassesMap.getOrPut(descriptor) {
createClass(descriptor).apply {
val functionClass = this
descriptor.declaredTypeParameters.mapTo(typeParameters) { typeParameterDescriptor ->
typeParameters += descriptor.declaredTypeParameters.map { typeParameterDescriptor ->
createTypeParameter(typeParameterDescriptor).also {
it.parent = this
it.superTypes += irBuiltIns.anyNType
@@ -134,7 +134,7 @@ internal class BuiltInFictitiousFunctionIrClassFactory(
}
val descriptorToIrParametersMap = typeParameters.map { it.descriptor to it }.toMap()
descriptor.typeConstructor.supertypes.mapTo(superTypes) { superType ->
superTypes += descriptor.typeConstructor.supertypes.map { superType ->
val arguments = superType.arguments.map { argument ->
val argumentClassifierDescriptor = argument.type.constructor.declarationDescriptor
val argumentClassifierSymbol = argumentClassifierDescriptor?.let { descriptorToIrParametersMap[it] }
@@ -165,7 +165,7 @@ internal class BuiltInFictitiousFunctionIrClassFactory(
typeParameters.last().defaultType
).apply {
parent = functionClass
invokeFunctionDescriptor.valueParameters.mapTo(valueParameters) {
valueParameters += invokeFunctionDescriptor.valueParameters.map {
IrValueParameterImpl(
SYNTHETIC_OFFSET, SYNTHETIC_OFFSET,
invokeFunctionOrigin,
@@ -170,9 +170,9 @@ internal class SpecialDeclarationsFactory(val context: Context) : KotlinMangler
dispatchReceiverParameter = dispatchReceiver?.copyTo(this)
extensionReceiverParameter = extensionReceiver?.copyTo(this)
function.valueParameters.mapTo(valueParameters) { it.copyTo(this, type = valueParameterTypes[it.index]) }
valueParameters += function.valueParameters.map { it.copyTo(this, type = valueParameterTypes[it.index]) }
function.typeParameters.mapIndexedTo(typeParameters) { index, parameter ->
typeParameters += function.typeParameters.mapIndexed { index, parameter ->
WrappedTypeParameterDescriptor().let {
IrTypeParameterImpl(
startOffset, endOffset,
@@ -44,7 +44,7 @@ internal fun makeEntryPoint(context: Context): IrFunction {
isFakeOverride = false,
isOperator = false
).also { function ->
function.valueParameters.add(WrappedValueParameterDescriptor().let {
function.valueParameters = listOf(WrappedValueParameterDescriptor().let {
IrValueParameterImpl(
actualMain.startOffset, actualMain.startOffset,
IrDeclarationOrigin.DEFINED,
@@ -1290,7 +1290,7 @@ private class ObjCBlockPointerValuePassing(
irClass.addChild(invokeMethod)
invokeMethod.createDispatchReceiverParameter()
(0 until parameterCount).mapTo(invokeMethod.valueParameters) { index ->
invokeMethod.valueParameters += (0 until parameterCount).map { index ->
val parameterDescriptor = WrappedValueParameterDescriptor()
val parameter = IrValueParameterImpl(
startOffset, endOffset,
@@ -97,8 +97,9 @@ class IrFileImpl(entry: SourceManager.FileEntry) : IrFile {
override val metadata: MetadataSource.File?
get() = TODO("not implemented")
override val annotations: MutableList<IrConstructorCall>
override var annotations: List<IrConstructorCall>
get() = TODO("not implemented")
set(_) = TODO("not implemented")
override val fqName: FqName
get() = TODO("not implemented")
override val symbol: IrFileSymbol
@@ -53,7 +53,7 @@ internal interface DescriptorToIrTranslationMixin {
descriptor = descriptor
).also { irClass ->
symbolTable.withScope(descriptor) {
descriptor.typeConstructor.supertypes.mapTo(irClass.superTypes) {
irClass.superTypes += descriptor.typeConstructor.supertypes.map {
it.toIrType()
}
irClass.generateAnnotations()
@@ -17,6 +17,7 @@ import org.jetbrains.kotlin.ir.declarations.*
import org.jetbrains.kotlin.ir.descriptors.IrBuiltIns
import org.jetbrains.kotlin.ir.expressions.IrExpression
import org.jetbrains.kotlin.ir.expressions.impl.IrEnumConstructorCallImpl
import org.jetbrains.kotlin.ir.expressions.impl.IrExpressionBodyImpl
import org.jetbrains.kotlin.ir.util.*
import org.jetbrains.kotlin.name.FqName
import org.jetbrains.kotlin.name.Name
@@ -119,14 +120,14 @@ internal class CEnumClassGenerator(
SYNTHETIC_OFFSET, SYNTHETIC_OFFSET,
IrDeclarationOrigin.IR_EXTERNAL_DECLARATION_STUB, entryDescriptor
).also { enumEntry ->
enumEntry.initializerExpression = IrEnumConstructorCallImpl(
enumEntry.initializerExpression = IrExpressionBodyImpl(IrEnumConstructorCallImpl(
SYNTHETIC_OFFSET, SYNTHETIC_OFFSET,
type = irBuiltIns.unitType,
symbol = symbolTable.referenceConstructor(enumDescriptor.unsubstitutedPrimaryConstructor!!),
typeArgumentsCount = 0 // enums can't be generic
).also {
it.putValueArgument(0, extractEnumEntryValue(entryDescriptor))
}
})
}
}
@@ -509,6 +509,6 @@ private val Context.getLoweredInlineClassConstructor: (IrConstructor) -> IrSimpl
).apply {
descriptor.bind(this)
parent = irConstructor.parent
irConstructor.valueParameters.mapTo(valueParameters) { it.copyTo(this) }
valueParameters += irConstructor.valueParameters.map { it.copyTo(this) }
}
}
@@ -268,7 +268,7 @@ internal class CallableReferenceLowering(val context: Context): FileLoweringPass
parent = functionReferenceClass
functionReferenceClass.declarations += this
boundFunctionParameters.mapIndexedTo(valueParameters) { index, parameter ->
valueParameters += boundFunctionParameters.mapIndexed { index, parameter ->
parameter.copyTo(this, DECLARATION_ORIGIN_FUNCTION_REFERENCE_IMPL, index,
type = parameter.type.substitute(typeArgumentsMap))
}
@@ -328,7 +328,7 @@ internal class CallableReferenceLowering(val context: Context): FileLoweringPass
this.createDispatchReceiverParameter()
superFunction.valueParameters.mapIndexedTo(valueParameters) { index, parameter ->
valueParameters += superFunction.valueParameters.mapIndexed { index, parameter ->
parameter.copyTo(function, DECLARATION_ORIGIN_FUNCTION_REFERENCE_IMPL, index,
type = parameter.type.substitute(typeArgumentsMap))
}
@@ -222,7 +222,7 @@ internal class EnumClassLowering(val context: Context) : ClassLoweringPass {
enumEntries
.sortedBy { it.name }
.map {
val initializer = it.initializerExpression
val initializer = it.initializerExpression?.expression
val entryConstructorCall = when {
initializer is IrConstructorCall -> initializer
@@ -289,7 +289,7 @@ internal class EnumClassLowering(val context: Context) : ClassLoweringPass {
dispatchReceiver = irGet(instances)
putValueArgument(0, irInt(it.index))
}
val initializer = it.value.initializerExpression!!
val initializer = it.value.initializerExpression!!.expression
initializer.setDeclarationsParent(constructor)
when {
initializer is IrConstructorCall -> +initInstanceCall(instance, initializer)
@@ -153,7 +153,7 @@ internal class EnumConstructorsLowering(val context: Context) : ClassLoweringPas
loweredConstructor.valueParameters += createSynthesizedValueParameter(0, "name", context.irBuiltIns.stringType)
loweredConstructor.valueParameters += createSynthesizedValueParameter(1, "ordinal", context.irBuiltIns.intType)
constructor.valueParameters.mapTo(loweredConstructor.valueParameters) {
loweredConstructor.valueParameters += constructor.valueParameters.map {
it.copyTo(loweredConstructor, index = it.loweredIndex).apply {
loweredEnumConstructorParameters[it] = this
}
@@ -262,9 +262,9 @@ private class InteropLoweringPart1(val context: Context) : BaseInteropIrTransfor
resultDescriptor.bind(result)
result.parent = irClass
result.createDispatchReceiverParameter()
constructor.valueParameters.mapTo(result.valueParameters) { it.copyTo(result) }
result.valueParameters += constructor.valueParameters.map { it.copyTo(result) }
result.overriddenSymbols.add(initMethod.symbol)
result.overriddenSymbols += initMethod.symbol
result.body = context.createIrBuilder(result.symbol).irBlockBody(result) {
+irReturn(
@@ -407,7 +407,7 @@ private class InteropLoweringPart1(val context: Context) : BaseInteropIrTransfor
}
}
parameterTypes.mapIndexedTo(newFunction.valueParameters) { index, type ->
newFunction.valueParameters += parameterTypes.mapIndexed { index, type ->
WrappedValueParameterDescriptor().let {
IrValueParameterImpl(
function.startOffset, function.endOffset,