Files
kotlin-fork/compiler/testData/codegen/box/delegatedProperty/provideDelegate/kt39588.kt
T
2021-11-20 03:37:31 +03:00

23 lines
989 B
Kotlin
Vendored

// IGNORE_BACKEND_FIR: JVM_IR
// FIR status: not supported in JVM IR
// IGNORE_BACKEND: JVM_IR
import kotlin.reflect.KProperty
class OptionDescriptor<T>
interface ArgumentValueDelegate<T> {
operator fun getValue(thisRef: Any?, property: KProperty<*>): T = "OK" as T
}
abstract class CLIEntity<TResult> constructor(val delegate: ArgumentValueDelegate<TResult>) {
operator fun provideDelegate(thisRef: Any?, prop: KProperty<*>): ArgumentValueDelegate<TResult> = delegate
}
abstract class AbstractSingleOption<T : Any, TResult> constructor(delegate: ArgumentValueDelegate<TResult>) : CLIEntity<TResult>(delegate)
class ArgumentSingleNullableValue<T : Any>(descriptor: OptionDescriptor<T>): ArgumentValueDelegate<T?>
class SingleNullableOption<T : Any> constructor(descriptor: OptionDescriptor<T>) : AbstractSingleOption<T, T?>(ArgumentSingleNullableValue(descriptor))
fun box(): String {
val x: List<Any>? by SingleNullableOption(OptionDescriptor())
return x.toString()
}