Files
kotlin-fork/compiler/fir/analysis-tests/testData/resolve/smartcasts/controlStructures/when.txt
T
2020-03-19 09:51:01 +03:00

111 lines
3.2 KiB
Plaintext
Vendored

FILE: when.kt
public abstract interface A : R|kotlin/Any| {
public abstract fun foo(): R|kotlin/Unit|
}
public abstract interface B : R|kotlin/Any| {
public abstract fun bar(): R|kotlin/Unit|
}
public final fun test_1(x: R|kotlin/Any?|): R|kotlin/Unit| {
when () {
(R|<local>/x| is R|A|) -> {
R|<local>/x|.R|/A.foo|()
}
(R|<local>/x| is R|B|) -> {
R|<local>/x|.R|/B.bar|()
}
}
when () {
(R|<local>/x| !is R|A|) -> {
}
(R|<local>/x| !is R|B|) -> {
R|<local>/x|.R|/A.foo|()
}
(R|<local>/x| is R|kotlin/Int|) -> {
R|<local>/x|.R|/A.foo|()
R|<local>/x|.R|/B.bar|()
R|<local>/x|.R|kotlin/Int.inc|()
}
else -> {
R|<local>/x|.R|/A.foo|()
R|<local>/x|.R|/B.bar|()
}
}
}
public final fun test_2(x: R|kotlin/Any?|): R|kotlin/Unit| {
when (R|<local>/x|) {
($subj$ is R|A|) -> {
R|<local>/x|.R|/A.foo|()
}
($subj$ is R|B|) -> {
R|<local>/x|.R|/B.bar|()
}
}
when (R|<local>/x|) {
($subj$ !is R|A|) -> {
}
($subj$ !is R|B|) -> {
R|<local>/x|.R|/A.foo|()
}
($subj$ is R|kotlin/Int|) -> {
R|<local>/x|.R|/A.foo|()
R|<local>/x|.R|/B.bar|()
R|<local>/x|.R|kotlin/Int.inc|()
}
else -> {
R|<local>/x|.R|/A.foo|()
R|<local>/x|.R|/B.bar|()
}
}
}
public final fun test_3(x: R|kotlin/Any?|): R|kotlin/Unit| {
when (lval y: R|kotlin/Any?| = R|<local>/x|) {
($subj$ is R|A|) -> {
R|<local>/x|.R|/A.foo|()
R|<local>/y|.R|/A.foo|()
}
($subj$ is R|B|) -> {
R|<local>/x|.R|/B.bar|()
R|<local>/y|.R|/B.bar|()
}
}
when (lval y: R|kotlin/Any?| = R|<local>/x|) {
($subj$ !is R|A|) -> {
}
($subj$ !is R|B|) -> {
R|<local>/x|.R|/A.foo|()
R|<local>/y|.R|/A.foo|()
}
($subj$ is R|kotlin/Int|) -> {
R|<local>/x|.R|/A.foo|()
R|<local>/x|.R|/B.bar|()
R|<local>/x|.R|kotlin/Int.inc|()
R|<local>/y|.R|/A.foo|()
R|<local>/y|.R|/B.bar|()
R|<local>/y|.R|kotlin/Int.inc|()
}
else -> {
R|<local>/x|.R|/A.foo|()
R|<local>/x|.R|/B.bar|()
R|<local>/y|.R|/A.foo|()
R|<local>/y|.R|/B.bar|()
}
}
}
public final fun test_4(x: R|kotlin/Any|): R|kotlin/Unit| {
when ((R|<local>/x| as R|kotlin/Int|)) {
==($subj$, Int(1)) -> {
R|<local>/x|.R|kotlin/Int.inc|()
}
}
R|<local>/x|.R|kotlin/Int.inc|()
}