Inference: handle Exact constraints with captured types properly

#KT-41818 Fixed
This commit is contained in:
Mikhail Glukhikh
2021-04-15 15:55:41 +03:00
parent 51d348d5fa
commit 9b3f1b9b8a
9 changed files with 80 additions and 3 deletions
@@ -0,0 +1,20 @@
// FIR_IDENTICAL
// FIR_DUMP
// WITH_REFLECT
import kotlin.reflect.KProperty
@Suppress("INVISIBLE_REFERENCE")
public operator fun <V, V1 : V> Map<in String, @kotlin.internal.Exact V>.getValue(thisRef: Any?, property: KProperty<*>): V1 = null!!
val m2: Map<String, *> = mapOf("baz" to "bat")
val bar: String get() = m2.getValue(null, ::bar)
fun foo() {
val m1: Map<String, Any> = mapOf("foo" to "bar")
val foo: String by m1
val baz: String by m2
println(foo) // bar
println(baz) // kotlin.KotlinNothingValueException
println(bar)
}