JVM IR: use correct owner for callable references in optimized multifile classes
The owner should always be the facade class, because the part class is package-private and will be inaccessible from other package. Note that in the old backend, function references already do have the facade as the owner correctly, but property references don't, this is reported as KT-37972.
This commit is contained in:
+36
@@ -0,0 +1,36 @@
|
||||
// TARGET_BACKEND: JVM
|
||||
// IGNORE_LIGHT_ANALYSIS
|
||||
// WITH_RUNTIME
|
||||
// !INHERIT_MULTIFILE_PARTS
|
||||
// FILE: box.kt
|
||||
|
||||
import a.funRefA
|
||||
import b.funRefB
|
||||
|
||||
fun box(): String {
|
||||
if (funRefA != funRefB) return "Fail: funRefA != funRefB"
|
||||
return "OK"
|
||||
}
|
||||
|
||||
// FILE: a.kt
|
||||
|
||||
package a
|
||||
|
||||
import test.function
|
||||
|
||||
val funRefA = ::function
|
||||
|
||||
// FILE: b.kt
|
||||
|
||||
package b
|
||||
|
||||
import test.function
|
||||
|
||||
val funRefB = ::function
|
||||
|
||||
// FILE: part.kt
|
||||
|
||||
@file:[JvmName("MultifileClass") JvmMultifileClass]
|
||||
package test
|
||||
|
||||
fun function() {}
|
||||
+37
@@ -0,0 +1,37 @@
|
||||
// TARGET_BACKEND: JVM
|
||||
// TODO: KT-37972 IllegalAccessError on initializing property reference for a property declared in JvmMultifileClass with -Xmultifile-parts-inherit
|
||||
// IGNORE_BACKEND: JVM
|
||||
// WITH_RUNTIME
|
||||
// !INHERIT_MULTIFILE_PARTS
|
||||
// FILE: box.kt
|
||||
|
||||
import a.propRefA
|
||||
import b.propRefB
|
||||
|
||||
fun box(): String {
|
||||
if (propRefA != propRefB) return "Fail: propRefA != propRefB"
|
||||
return "OK"
|
||||
}
|
||||
|
||||
// FILE: a.kt
|
||||
|
||||
package a
|
||||
|
||||
import test.property
|
||||
|
||||
val propRefA = ::property
|
||||
|
||||
// FILE: b.kt
|
||||
|
||||
package b
|
||||
|
||||
import test.property
|
||||
|
||||
val propRefB = ::property
|
||||
|
||||
// FILE: part.kt
|
||||
|
||||
@file:[JvmName("MultifileClass") JvmMultifileClass]
|
||||
package test
|
||||
|
||||
val property: String get() = ""
|
||||
Reference in New Issue
Block a user