FIR2IR: cache type parameters in delegated property
#KT-44030 Fixed
This commit is contained in:
committed by
Mikhail Glukhikh
parent
78fa8814c4
commit
e05d26b9b0
@@ -0,0 +1,76 @@
|
||||
class SettingType<out V : Any> {
|
||||
constructor(type: KClass<out V>) /* primary */ {
|
||||
super/*Any*/()
|
||||
/* <init>() */
|
||||
|
||||
}
|
||||
|
||||
val type: KClass<out V>
|
||||
field = type
|
||||
get
|
||||
|
||||
}
|
||||
|
||||
class SettingReference<V : Any, T : SettingType<V>> {
|
||||
constructor(t: T, v: V) /* primary */ {
|
||||
super/*Any*/()
|
||||
/* <init>() */
|
||||
|
||||
}
|
||||
|
||||
var t: T
|
||||
field = t
|
||||
get
|
||||
set
|
||||
|
||||
var v: V
|
||||
field = v
|
||||
get
|
||||
set
|
||||
|
||||
}
|
||||
|
||||
class IdeWizard {
|
||||
constructor() /* primary */ {
|
||||
super/*Any*/()
|
||||
/* <init>() */
|
||||
|
||||
}
|
||||
|
||||
var projectTemplate: Int? /* by */
|
||||
field = <this>.setting<Int, SettingType<Int>>(reference = SettingReference<Int, SettingType<Int>>(t = SettingType<Int>(type = 42::class), v = 42))
|
||||
get(): Int? {
|
||||
return <this>.#projectTemplate$delegate.getValue(thisRef = <this>, property = IdeWizard::projectTemplate)
|
||||
}
|
||||
set(<set-?>: Int?) {
|
||||
return <this>.#projectTemplate$delegate.setValue(thisRef = <this>, property = IdeWizard::projectTemplate, value = <set-?>)
|
||||
}
|
||||
|
||||
private fun <V : Any, T : SettingType<V>> setting(reference: SettingReference<V, T>): <no name provided><V, T> {
|
||||
return { // BLOCK
|
||||
local class <no name provided> : ReadWriteProperty<Any?, V?> {
|
||||
constructor() /* primary */ {
|
||||
super/*Any*/()
|
||||
/* <init>() */
|
||||
|
||||
}
|
||||
|
||||
override operator fun setValue(thisRef: Any?, property: KProperty<*>, value: V?) {
|
||||
when {
|
||||
EQEQ(arg0 = value, arg1 = null) -> return Unit
|
||||
}
|
||||
reference.<set-t>(<set-?> = SettingType<V>(type = value::class) as T)
|
||||
reference.<set-v>(<set-?> = value)
|
||||
}
|
||||
|
||||
override operator fun getValue(thisRef: Any?, property: KProperty<*>): V? {
|
||||
return reference.<get-v>()
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
<no name provided>()
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
Reference in New Issue
Block a user