[FIR] Add tests for non exhaustive when as last expression of lambda
KT-44810
This commit is contained in:
+15
@@ -0,0 +1,15 @@
|
||||
FILE: nonExhaustiveWhenWithoutCoercionToUnit.kt
|
||||
public final fun <T> run(block: R|() -> T|): R|T| {
|
||||
^run R|<local>/block|.R|SubstitutionOverride<kotlin/Function0.invoke: R|T|>|()
|
||||
}
|
||||
public final fun test(a: R|kotlin/Any|): R|kotlin/Unit| {
|
||||
R|/run|<R|kotlin/Unit|>(<L> = run@fun <anonymous>(): R|kotlin/Unit| {
|
||||
when (R|<local>/a|) {
|
||||
($subj$ is R|kotlin/String|) -> {
|
||||
Int(1)
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
)
|
||||
}
|
||||
+10
@@ -0,0 +1,10 @@
|
||||
fun <T> run(block: () -> T): T = block()
|
||||
|
||||
fun test(a: Any) {
|
||||
run {
|
||||
// Should be an error, see KT-44810
|
||||
when (a) {
|
||||
is String -> 1
|
||||
}
|
||||
}
|
||||
}
|
||||
+21
@@ -0,0 +1,21 @@
|
||||
FILE: nonExhaustiveWhenWithCoercionToUnit.kt
|
||||
public final fun <T> run(block: R|() -> T|): R|T| {
|
||||
^run R|<local>/block|.R|SubstitutionOverride<kotlin/Function0.invoke: R|T|>|()
|
||||
}
|
||||
public final fun test(a: R|kotlin/Any|, b: R|kotlin/Boolean|): R|kotlin/Unit| {
|
||||
R|/run|<R|kotlin/Unit|>(<L> = run@fun <anonymous>(): R|kotlin/Unit| {
|
||||
when () {
|
||||
R|<local>/b| -> {
|
||||
^@run Unit
|
||||
}
|
||||
}
|
||||
|
||||
when (R|<local>/a|) {
|
||||
($subj$ is R|kotlin/String|) -> {
|
||||
Int(1)
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
)
|
||||
}
|
||||
+10
@@ -0,0 +1,10 @@
|
||||
fun <T> run(block: () -> T): T = block()
|
||||
|
||||
fun test(a: Any, b: Boolean) {
|
||||
run {
|
||||
if (b) return@run
|
||||
when (a) {
|
||||
is String -> 1
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user