[FIR, Tests] Add box tests to verify that disappeared DELEGATE_SPECIAL_FUNCTION_NONE_APPLICABLE leads to executable code
#KT-59903 Merge-request: KT-MR-13423 Merged-by: Evgeniy Zhelenskiy <Evgeniy.Zhelenskiy@jetbrains.com>
This commit is contained in:
committed by
Space Team
parent
aff5b91da3
commit
9cef8a2133
Vendored
+33
@@ -0,0 +1,33 @@
|
||||
// ISSUE: KT-58013
|
||||
// WITH_STDLIB
|
||||
// WITH_REFLECT
|
||||
// FIR_DUMP
|
||||
// IGNORE_BACKEND_K1: ANY
|
||||
|
||||
|
||||
import kotlin.reflect.KProperty
|
||||
|
||||
data class Ref<D>(val t: D)
|
||||
|
||||
class GenericDelegate<G>(val value: G)
|
||||
|
||||
operator fun <V> Ref<V>.provideDelegate(a: Any?, p: KProperty<*>): GenericDelegate<V> = GenericDelegate(this.t)
|
||||
|
||||
operator fun <W> GenericDelegate<W>.getValue(a: Any?, p: KProperty<*>): W = this.value
|
||||
|
||||
fun <E> List<Ref<*>>.getElement(i: Int): Ref<E> = this[i] as Ref<E>
|
||||
|
||||
@Suppress("UNNECESSARY_NOT_NULL_ASSERTION")
|
||||
fun test(list: List<Ref<*>>) {
|
||||
val data: String by list.getElement(0)!!
|
||||
require(data == list[0].t)
|
||||
|
||||
val data2: String by list.getElement(0)
|
||||
require(data2 == list[0].t)
|
||||
}
|
||||
|
||||
fun box(): String {
|
||||
test(listOf(Ref("q")))
|
||||
|
||||
return "OK"
|
||||
}
|
||||
Reference in New Issue
Block a user