Files
kotlin-fork/compiler/fir/analysis-tests/testData/resolve/smartcasts/boundSmartcasts/boundSmartcasts.txt
T
Dmitriy Novozhilov 102c9c08d0 [FIR] Resolve elvis call as special synthetic call
Before that commit we desugared `a ?: b` as

when (val elvis = a) {
    null -> b
    else -> elvis
}

It was incorrect, because `a` should be resolved in dependent mode,
  but when it was `elvis` initializer it was resolved in independent
  mode, so we can't infer type for `a` in some complex cases
2020-07-02 15:10:51 +03:00

94 lines
2.8 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| = R|<local>/d|.R|/D.any| ?: ^test_5 Unit
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|()
}