Files
pyos 16b8811697 FIR DFA: take all statements from ?. if result is non-null.
I.e. a?.f(b as T) != null => b is T.

This also allows to remove the copyAllInformationFrom hack by moving the
edge directly in the control flow graph.
2022-12-08 10:19:28 +00:00

30 lines
923 B
Plaintext
Vendored

FILE: safeCalls.kt
public abstract interface A : R|kotlin/Any| {
public abstract fun foo(): R|A|
public abstract fun bar(x: R|kotlin/String|): R|A|
}
public abstract interface B : R|kotlin/Any| {
public abstract val foo: R|B|
public get(): R|B|
public abstract val bar: R|B|
public get(): R|B|
}
public final fun test_1(x: R|A?|): R|kotlin/Unit| {
R|<local>/x|?.{ $subj$.R|/A.foo|() }?.{ $subj$.R|/A.bar|(String()) }
}
public final fun test_2(x: R|B?|): R|kotlin/Unit| {
R|<local>/x|?.{ $subj$.R|/B.foo| }?.{ $subj$.R|/B.bar| }
}
public final fun test_3(x: R|A?|, y: R|kotlin/String?|): R|kotlin/Unit| {
when () {
!=(R|<local>/x|?.{ $subj$.R|/A.bar|((R|<local>/y| as R|kotlin/String|)) }, Null(null)) -> {
R|<local>/y|.R|kotlin/String.length|
}
}
}