IR: minor, make IrClass.companionObject return IrClass
This commit is contained in:
+1
-1
@@ -166,7 +166,7 @@ class IrEfficientParcelableParcelSerializer(private val irClass: IrClass) : IrPa
|
||||
val creator: IrExpression = irClass.fields.find { it.name == CREATOR_NAME }?.let { creatorField ->
|
||||
irGetField(null, creatorField)
|
||||
} ?: irCall(irClass.creatorGetter!!).apply {
|
||||
dispatchReceiver = irGetObject((irClass.companionObject()!! as IrClass).symbol)
|
||||
dispatchReceiver = irGetObject(irClass.companionObject()!!.symbol)
|
||||
}
|
||||
|
||||
return parcelableCreatorCreateFromParcel(creator, irGet(parcel))
|
||||
|
||||
+2
-2
@@ -14,8 +14,8 @@ import org.jetbrains.kotlin.backend.common.ir.createImplicitParameterDeclaration
|
||||
import org.jetbrains.kotlin.backend.common.lower.DeclarationIrBuilder
|
||||
import org.jetbrains.kotlin.backend.jvm.ir.erasedUpperBound
|
||||
import org.jetbrains.kotlin.descriptors.ClassKind
|
||||
import org.jetbrains.kotlin.descriptors.Modality
|
||||
import org.jetbrains.kotlin.descriptors.DescriptorVisibilities
|
||||
import org.jetbrains.kotlin.descriptors.Modality
|
||||
import org.jetbrains.kotlin.ir.IrElement
|
||||
import org.jetbrains.kotlin.ir.IrStatement
|
||||
import org.jetbrains.kotlin.ir.ObsoleteDescriptorBasedAPI
|
||||
@@ -107,7 +107,7 @@ class ParcelableIrTransformer(private val context: IrPluginContext, private val
|
||||
val parcelableProperties = declaration.parcelableProperties
|
||||
|
||||
// If the companion extends Parceler, it can override parts of the generated implementation.
|
||||
val parcelerObject = declaration.companionObject()?.safeAs<IrClass>()?.takeIf {
|
||||
val parcelerObject = declaration.companionObject()?.takeIf {
|
||||
it.isSubclassOfFqName(PARCELER_FQNAME.asString())
|
||||
}
|
||||
|
||||
|
||||
+1
-2
@@ -26,7 +26,6 @@ import org.jetbrains.kotlin.ir.types.*
|
||||
import org.jetbrains.kotlin.ir.util.*
|
||||
import org.jetbrains.kotlin.name.FqName
|
||||
import org.jetbrains.kotlin.types.Variance
|
||||
import org.jetbrains.kotlin.utils.addToStdlib.safeAs
|
||||
|
||||
// true if the class should be processed by the parcelize plugin
|
||||
val IrClass.isParcelize: Boolean
|
||||
@@ -34,7 +33,7 @@ val IrClass.isParcelize: Boolean
|
||||
|
||||
// Finds the getter for a pre-existing CREATOR field on the class companion, which is used for manual Parcelable implementations in Kotlin.
|
||||
val IrClass.creatorGetter: IrSimpleFunctionSymbol?
|
||||
get() = companionObject()?.safeAs<IrClass>()?.getPropertyGetter(CREATOR_NAME.asString())?.takeIf {
|
||||
get() = companionObject()?.getPropertyGetter(CREATOR_NAME.asString())?.takeIf {
|
||||
it.owner.correspondingPropertySymbol?.owner?.backingField?.hasAnnotation(FqName("kotlin.jvm.JvmField")) == true
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user