Files
kotlin-fork/compiler/fir/analysis-tests/testData/resolve/smartcasts/boundSmartcasts/boundSmartcasts.txt
T
2020-06-03 10:43:37 +03:00

102 lines
3.0 KiB
Plaintext
Vendored

FILE: boundSmartcasts.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| {
lval y: R|kotlin/Any| = R|<local>/x|
when () {
(R|<local>/x| is R|A|) -> {
R|<local>/x|.R|/A.foo|()
R|<local>/y|.R|/A.foo|()
}
}
}
public final fun test_2(x: R|kotlin/Any|): R|kotlin/Unit| {
lval y: R|kotlin/Any| = R|<local>/x|
when () {
(R|<local>/y| is R|A|) -> {
R|<local>/x|.R|/A.foo|()
R|<local>/y|.R|/A.foo|()
}
}
}
public final fun test_3(x: R|kotlin/Any|, y: R|kotlin/Any|): R|kotlin/Unit| {
lvar z: R|kotlin/Any| = R|<local>/x|
when () {
(R|<local>/x| is R|A|) -> {
R|<local>/z|.R|/A.foo|()
}
}
R|<local>/z| = R|<local>/y|
when () {
(R|<local>/y| is R|B|) -> {
R|<local>/z|.<Unresolved name: foo>#()
R|<local>/z|.R|/B.bar|()
}
}
}
public final fun test_4(y: R|kotlin/Any|): R|kotlin/Unit| {
lvar x: R|kotlin/Any| = Int(1)
(R|<local>/x| as R|kotlin/Int|)
R|<local>/x|.R|kotlin/Int.inc|()
R|<local>/x| = R|<local>/y|
R|<local>/x|.<Unresolved name: inc>#()
when () {
(R|<local>/y| is R|A|) -> {
R|<local>/x|.R|/A.foo|()
R|<local>/y|.R|/A.foo|()
}
}
}
public final class D : R|kotlin/Any| {
public constructor(any: R|kotlin/Any?|): R|D| {
super<R|kotlin/Any|>()
}
public final val any: R|kotlin/Any?| = R|<local>/any|
public get(): R|kotlin/Any?|
}
public final fun R|kotlin/Any|.baz(): R|kotlin/Unit| {
}
public final fun test_5(d: R|D|): R|kotlin/Unit| {
lval a: R|kotlin/Any| = when (lval <elvis>: R|kotlin/Any?| = R|<local>/d|.R|/D.any|) {
==($subj$, Null(null)) -> {
^test_5 Unit
}
else -> {
R|<local>/<elvis>|
}
}
R|<local>/a|.R|/baz|()
R|<local>/d|.R|/D.any|.R|/baz|()
(R|<local>/a| as R|A|)
R|<local>/a|.R|/A.foo|()
}
public final fun test_6(d1: R|D|): R|kotlin/Unit| {
lval a: R|kotlin/Any?| = R|<local>/d1|.R|/D.any|
(R|<local>/a| as R|A|)
R|<local>/a|.R|/A.foo|()
R|<local>/d1|.R|/D.any|.R|/A.foo|()
R|<local>/d1|.R|/D.any|.R|/baz|()
}
public final fun test_7(d1: R|D|, d2: R|D|): R|kotlin/Unit| {
lval a: R|kotlin/Any?| = R|<local>/d1|?.{ $subj$.R|/D.any| }
lval b: R|kotlin/Any?| = R|<local>/d2|?.{ $subj$.R|/D.any| }
(R|<local>/a| as R|A|)
R|<local>/a|.R|/A.foo|()
(R|<local>/b| as R|B|)
R|<local>/b|.R|/B.bar|()
}