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:
@@ -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")!!
|
||||
|
||||
+3
-5
@@ -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")!!
|
||||
|
||||
Reference in New Issue
Block a user