PSI2IR/FIR2IR: do not approximate T!! before translation

This leads to weird effects when it's in a contravariant position,
because it's approximated by Nothing.
This commit is contained in:
pyos
2021-05-10 13:12:02 +02:00
committed by teamcityserver
parent a37db99841
commit d5d6736e67
7 changed files with 35 additions and 22 deletions
@@ -1,11 +1,7 @@
// IGNORE_BACKEND: JVM_IR
// IGNORE_BACKEND_FIR: JVM_IR
// DONT_TARGET_EXACT_BACKEND: WASM
// WASM_MUTE_REASON: CALLABLE_REFERENCES_FAIL
fun <T> id(x: T): T = x
fun <T> String.extId(x: T): T = x
fun <T> foo(value: T?): T? = value?.let(::id) // KFunction1<Nothing, T>
fun <T> foo(value: T?): T? = value?.let(::id) // ::id = KFunction1<T!!, T!!>
fun <T> bar(value: T?): T? = value?.let(""::extId)
fun box() = foo("O")!! + foo("K")!!
fun box() = foo("O")!! + bar("K")!!
@@ -1,13 +1,11 @@
// IGNORE_BACKEND: JVM_IR
// IGNORE_BACKEND_FIR: JVM_IR
// DONT_TARGET_EXACT_BACKEND: WASM
// WASM_MUTE_REASON: CALLABLE_REFERENCES_FAIL
// WASM_MUTE_REASON: BINDING_RECEIVERS
fun <T> id(x: T): T = x
fun <T> String.extId(x: T): T = x
fun <T, R> T.myLet(block: (T) -> R): R = block(this)
fun <T> foo(value: T?): T? = value?.myLet(::id) // KFunction1<Nothing, T>
fun <T> foo(value: T?): T? = value?.myLet(::id) // ::id = KFunction1<T!!, T!!>
fun <T> bar(value: T?): T? = value?.myLet(""::extId)
fun box() = foo("O")!! + foo("K")!!
fun box() = foo("O")!! + bar("K")!!