Files
kotlin-fork/compiler/testData/diagnostics/tests/delegatedProperty/noInferenceFromGetValueThroughSetValue.fir.kt
T
Denis.Zharkov 033ff38fef K2: Adjust diagnostic test data after delegate inference is rewritten
In all tests, some red-code diagnostics have changed insignificantly
to some other combination or red-code diagnostics

^KT-61060 Related
2023-09-08 07:11:48 +00:00

25 lines
789 B
Kotlin
Vendored

import kotlin.reflect.KProperty
// Definitions
class M<E>
operator fun <X> M<out X>.getValue(thisRef: Any?, property: KProperty<*>): String = "value"
operator fun <Z> M<in Z>.setValue(thisRef: Any?, property: KProperty<*>, value: Z) {}
fun <U> m(): M<U> = M()
// We don't allow to infer type of a delegate expression through a setValue, where the argument (value) is constrained by the return type of a getValue
var a by <!DELEGATE_SPECIAL_FUNCTION_NONE_APPLICABLE!><!NEW_INFERENCE_NO_INFORMATION_FOR_PARAMETER, NEW_INFERENCE_NO_INFORMATION_FOR_PARAMETER!>m<!>()<!>
// We infer type of delegate expression through a setValue from the explicit property type
var b: String by m()
fun takeString(v: String) {}
fun main() {
takeString(a)
a = "a"
takeString(b)
b = "b"
}