Change base class of property reference classes

This commit is contained in:
Tamas Vajk
2022-03-18 12:48:26 +01:00
committed by Ian Lynagh
parent cf0be05b44
commit 257224aa59
2 changed files with 10 additions and 6 deletions

View File

@@ -2944,6 +2944,10 @@ open class KotlinFileExtractor(
getterParameterTypes: List<IrType>,
getterReturnType: IrType
) {
// Extracting this method is not (strictly) needed for interface member implementation.
// `[Mutable]PropertyReferenceX` already implements it, but its signature doesn't match the
// generic one, because it's a raw method implementation. Also, by adding the `invoke` explicitly,
// we have better data flow analysis support.
val invokeLabels = addFunctionManual(tw.getFreshIdLabel(), OperatorNameConventions.INVOKE.asString(), getterParameterTypes, getterReturnType, classId, locId)
// return this.get(a0, a1, ...)
@@ -3017,8 +3021,8 @@ open class KotlinFileExtractor(
)
val currentDeclaration = declarationStack.peek()
// The base class could be `Any`. `PropertyReference` is used to keep symmetry with function references.
val baseClass = pluginContext.referenceClass(FqName("kotlin.jvm.internal.PropertyReference"))?.owner?.typeWith()
val prefix = if (kPropertyType.classOrNull!!.owner.name.asString().startsWith("KMutableProperty")) "Mutable" else ""
val baseClass = pluginContext.referenceClass(FqName("kotlin.jvm.internal.${prefix}PropertyReference${kPropertyType.arguments.size - 1}"))?.owner?.typeWith()
?: pluginContext.irBuiltIns.anyType
val classId = extractGeneratedClass(ids, listOf(baseClass, kPropertyType), locId, currentDeclaration)