IR: add IrClass.getInlineClassRepresentation, serialize/deserialize it
The change in FirDeclarationUtil is needed because in case of unsigned types loaded from the standard library, the primary constructor for some reason is not the first, but the second in the list of constructors.
This commit is contained in:
@@ -29,6 +29,7 @@ import org.jetbrains.kotlin.ir.expressions.impl.IrReturnImpl
|
||||
import org.jetbrains.kotlin.ir.expressions.mapValueParameters
|
||||
import org.jetbrains.kotlin.ir.expressions.putTypeArguments
|
||||
import org.jetbrains.kotlin.ir.expressions.typeParametersCount
|
||||
import org.jetbrains.kotlin.ir.types.IrSimpleType
|
||||
import org.jetbrains.kotlin.ir.util.SYNTHETIC_OFFSET
|
||||
import org.jetbrains.kotlin.ir.util.createIrClassFromDescriptor
|
||||
import org.jetbrains.kotlin.ir.util.declareSimpleFunctionWithOverrides
|
||||
@@ -121,6 +122,11 @@ class ClassGenerator(
|
||||
generateFakeOverrideMemberDeclarations(irClass, ktClassOrObject)
|
||||
|
||||
if (irClass.isInline && ktClassOrObject is KtClassOrObject) {
|
||||
val representation = classDescriptor.inlineClassRepresentation
|
||||
?: error("Unknown representation for inline class: $classDescriptor")
|
||||
irClass.inlineClassRepresentation = representation.mapUnderlyingType { type ->
|
||||
type.toIrType() as? IrSimpleType ?: error("Inline class underlying type is not a simple type: $classDescriptor")
|
||||
}
|
||||
generateAdditionalMembersForInlineClasses(irClass, ktClassOrObject)
|
||||
}
|
||||
|
||||
|
||||
+6
-1
@@ -10,6 +10,7 @@ import org.jetbrains.kotlin.ir.IrElement
|
||||
import org.jetbrains.kotlin.ir.declarations.*
|
||||
import org.jetbrains.kotlin.ir.expressions.IrExpressionBody
|
||||
import org.jetbrains.kotlin.ir.symbols.*
|
||||
import org.jetbrains.kotlin.ir.types.IrSimpleType
|
||||
import org.jetbrains.kotlin.ir.types.impl.IrUninitializedType
|
||||
import org.jetbrains.kotlin.ir.util.createIrClassFromDescriptor
|
||||
import org.jetbrains.kotlin.ir.util.withScope
|
||||
@@ -76,7 +77,9 @@ class StandaloneDeclarationGenerator(private val context: GeneratorContext) {
|
||||
}
|
||||
}
|
||||
|
||||
fun generateClass(startOffset: Int, endOffset: Int, origin: IrDeclarationOrigin, descriptor: ClassDescriptor, symbol: IrClassSymbol): IrClass {
|
||||
fun generateClass(
|
||||
startOffset: Int, endOffset: Int, origin: IrDeclarationOrigin, descriptor: ClassDescriptor, symbol: IrClassSymbol
|
||||
): IrClass {
|
||||
val irClass = irFactory.createIrClassFromDescriptor(startOffset, endOffset, origin, symbol, descriptor)
|
||||
|
||||
symbolTable.withScope(irClass) {
|
||||
@@ -93,6 +96,8 @@ class StandaloneDeclarationGenerator(private val context: GeneratorContext) {
|
||||
descriptor.thisAsReceiverParameter,
|
||||
descriptor.thisAsReceiverParameter.type.toIrType()
|
||||
).also { it.parent = irClass }
|
||||
|
||||
irClass.inlineClassRepresentation = descriptor.inlineClassRepresentation?.mapUnderlyingType { it.toIrType() as IrSimpleType }
|
||||
}
|
||||
|
||||
return irClass
|
||||
|
||||
Reference in New Issue
Block a user