FIR: Replicate coercion-to-unit behavior from FE 1.0

This commit is contained in:
Denis.Zharkov
2021-04-27 15:09:15 +03:00
committed by teamcityserver
parent dac5c31993
commit c67ae8a0a3
10 changed files with 109 additions and 30 deletions
@@ -0,0 +1,18 @@
FILE: elvisAndUnit.kt
public final fun foo(x: R|(kotlin/Int) -> kotlin/Unit|): R|kotlin/Unit| {
}
public final class A : R|kotlin/Any| {
public constructor(): R|A| {
super<R|kotlin/Any|>()
}
public final fun bar(): R|kotlin/Unit| {
}
}
public final fun main(a: R|A?|, y: R|kotlin/String|): R|kotlin/Unit| {
R|/foo|(<L> = foo@fun <anonymous>(it: R|kotlin/Int|): R|kotlin/Unit| <inline=NoInline> {
R|<local>/a|?.{ $subj$.R|/A.bar|() } ?: R|<local>/y|.R|kotlin/String.get|(Int(0))
}
)
}
@@ -0,0 +1,11 @@
fun foo(x: (Int) -> Unit) {}
class A {
fun bar() {}
}
fun main(a: A?, y: String) {
foo {
a?.bar() ?: y.get(0)
}
}