JVM IR: change generation scheme of property $delegate methods
Generate $delegate method as instance method in PropertyReferenceDelegationLowering, and remove dispatch receiver later in MakePropertyDelegateMethodsStatic. The method needs to be static to be non-overridable (see delegateMethodIsNonOverridable.kt), and public to be accessible in reflection. Otherwise we generated incorrect IR where a static function accessed an instance field of the containing class, which failed in multiple places including LocalDeclarationsLowering. #KT-48350 Fixed
This commit is contained in:
committed by
Alexander Udalov
parent
50508da156
commit
04c5bbdcf8
Vendored
+20
@@ -0,0 +1,20 @@
|
||||
// WITH_RUNTIME
|
||||
|
||||
import kotlin.reflect.KProperty
|
||||
|
||||
class DP {
|
||||
operator fun provideDelegate(t: Any?, kp: KProperty<*>) =
|
||||
lazy { "OK" }
|
||||
}
|
||||
|
||||
class H1 {
|
||||
companion object {
|
||||
val property: String by DP()
|
||||
}
|
||||
}
|
||||
|
||||
class H2 {
|
||||
companion object {
|
||||
val property: String by lazy { "OK" }
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user