Files
kotlin-fork/compiler/fir/analysis-tests/testData/resolve/smartcasts/longElvisChain.fir.txt
T
Brian Norman 8ac59592ed [FIR] Add DFA implications when one side of an Elvis operator is null
When one side of an Elvis operator can only be `null`, and the entire
Elvis operator expression cannot be `null`, this implies that the
opposite side of the Elvis operator cannot be `null`. Add such
implications to the Elvis exit node of the DFA. This helps smart-casting
of variables used within long Elvis operator chains.

#KT-49249 Fixed
2023-06-19 08:17:47 +00:00

40 lines
1.9 KiB
Plaintext
Vendored

FILE: longElvisChain.kt
public final fun test_1(): R|kotlin/Unit| {
lval a: R|kotlin/Throwable?| = Null(null)
lval b: R|kotlin/Unit?| = Null(null)
lval c: R|kotlin/Throwable| = R|<local>/a| ?: R|<local>/b|?.{ $subj$.R|kotlin/let|<R|kotlin/Unit|, R|kotlin/Nothing|>(<L> = let@fun <anonymous>(it: R|kotlin/Unit|): R|kotlin/Nothing| <inline=Inline, kind=EXACTLY_ONCE> {
^test_1 R|<local>/it|
}
) } ?: ^test_1 Unit
R|<local>/c|!!
throw R|<local>/a|
}
public final fun test_2(): R|kotlin/Unit| {
lval a: R|kotlin/Throwable?| = Null(null)
lval b: R|kotlin/Unit?| = Null(null)
lval c: R|kotlin/Throwable| = R|<local>/a| ?: R|<local>/b|?.{ $subj$.R|kotlin/let|<R|kotlin/Unit|, R|kotlin/Nothing|>(<L> = let@fun <anonymous>(it: R|kotlin/Unit|): R|kotlin/Nothing| <inline=Inline, kind=EXACTLY_ONCE> {
^test_2 R|<local>/it|
}
) } ?: ^test_2 Unit
throw R|<local>/a|
}
public final fun test_3(): R|kotlin/Unit| {
lval a: R|kotlin/Throwable?| = Null(null)
lval b: R|kotlin/Unit?| = Null(null)
lval c: R|kotlin/Throwable| = R|<local>/b|?.{ $subj$.R|kotlin/let|<R|kotlin/Unit|, R|kotlin/Nothing|>(<L> = let@fun <anonymous>(it: R|kotlin/Unit|): R|kotlin/Nothing| <inline=Inline, kind=EXACTLY_ONCE> {
^test_3 R|<local>/it|
}
) } ?: R|<local>/a| ?: ^test_3 Unit
R|<local>/c|!!
throw R|<local>/a|
}
public final fun test_4(): R|kotlin/Unit| {
lval a: R|kotlin/Throwable?| = Null(null)
lval b: R|kotlin/Unit?| = Null(null)
lval c: R|kotlin/Throwable| = R|<local>/b|?.{ $subj$.R|kotlin/let|<R|kotlin/Unit|, R|kotlin/Nothing|>(<L> = let@fun <anonymous>(it: R|kotlin/Unit|): R|kotlin/Nothing| <inline=Inline, kind=EXACTLY_ONCE> {
^test_4 R|<local>/it|
}
) } ?: R|<local>/a| ?: ^test_4 Unit
throw R|<local>/a|
}