Skip to content

Commit 85fbf4b

Browse files
authored
Merge pull request github#10767 from tamasvajk/kotlin-prop-ref-fix
Kotlin: adjust extracted property reference base class
2 parents 6ef5fac + 43f9331 commit 85fbf4b

File tree

6 files changed

+289
-8
lines changed

6 files changed

+289
-8
lines changed

java/kotlin-extractor/src/main/kotlin/KotlinFileExtractor.kt

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -4243,9 +4243,11 @@ open class KotlinFileExtractor(
42434243
* this.dispatchReceiver = dispatchReceiver
42444244
* }
42454245
*
4246-
* fun get(): R { return this.dispatchReceiver.FN1() }
4246+
* override fun get(): R { return this.dispatchReceiver.FN1() }
42474247
*
4248-
* fun set(a0: R): Unit { return this.dispatchReceiver.FN2(a0) }
4248+
* override fun set(a0: R): Unit { return this.dispatchReceiver.FN2(a0) }
4249+
*
4250+
* override fun invoke(): R { return this.get() }
42494251
* }
42504252
* ```
42514253
*
@@ -4283,8 +4285,8 @@ open class KotlinFileExtractor(
42834285
)
42844286

42854287
val declarationParent = peekDeclStackAsDeclarationParent(propertyReferenceExpr) ?: return
4286-
val prefix = if (kPropertyClass.owner.name.asString().startsWith("KMutableProperty")) "Mutable" else ""
4287-
val baseClass = pluginContext.referenceClass(FqName("kotlin.jvm.internal.${prefix}PropertyReference${kPropertyType.arguments.size - 1}"))?.owner?.typeWith()
4288+
// The base class could be `Any`. `PropertyReference` is used to keep symmetry with function references.
4289+
val baseClass = pluginContext.referenceClass(FqName("kotlin.jvm.internal.PropertyReference"))?.owner?.typeWith()
42884290
?: pluginContext.irBuiltIns.anyType
42894291

42904292
val classId = extractGeneratedClass(ids, listOf(baseClass, kPropertyType), locId, propertyReferenceExpr, declarationParent)

0 commit comments

Comments
 (0)