Files
kotlin-fork/compiler/fir/analysis-tests/testData/resolve/smartcasts/safeCalls/safeCalls.fir.txt
T
Tianyu Geng 6a03f31e50 FIR: add UnsafeCall resolution diagnostics
Previously unsafe call is reported as part of InapplicableWrongReceiver.
This makes it difficult for the downstream checkers to report different
diagnostics.
2021-04-19 15:11:13 +03:00

42 lines
1.8 KiB
Plaintext
Vendored

FILE: safeCalls.kt
public final fun R|kotlin/String|.foo(b: R|kotlin/Boolean|): R|kotlin/String| {
^foo String()
}
public final fun R|kotlin/String|.let(block: R|() -> kotlin/Unit|): R|kotlin/Unit| {
}
public final fun test(x: R|kotlin/String?|): R|kotlin/Unit| {
R|<local>/x|?.{ $subj$.R|/foo|(==(R|<local>/x|.R|kotlin/String.length|, Int(1))) }
R|<local>/x|.<Inapplicable(UNSAFE_CALL): kotlin/String.length>#
}
public abstract interface A : R|kotlin/Any| {
public abstract fun bar(a: R|A|): R|kotlin/String|
public abstract fun bool(): R|kotlin/Boolean|
public abstract fun id(): R|A|
}
public final fun test_2(x: R|kotlin/Any|): R|kotlin/Unit| {
(R|<local>/x| as? R|A|)?.{ $subj$.R|/A.bar|(R|<local>/x|) }
}
public final fun test_3(x: R|kotlin/Any|): R|kotlin/Unit| {
(R|<local>/x| as? R|A|)?.{ $subj$.R|/A.bar|(R|<local>/x|) }?.{ $subj$.R|/foo|(R|<local>/x|.R|/A.bool|()) }?.{ $subj$.R|/let|(<L> = let@fun <anonymous>(): R|kotlin/Unit| <inline=NoInline> {
R|<local>/x|.R|/A.bool|()
}
) }
R|<local>/x|.<Unresolved name: bool>#()
}
public final fun test_4(x: R|A?|): R|kotlin/Unit| {
R|<local>/x|?.{ $subj$.R|/A.id|() }?.{ $subj$.R|/A.bool|() }
R|<local>/x|.<Inapplicable(UNSAFE_CALL): /A.id>#()
}
public final fun R|kotlin/Any?|.boo(b: R|kotlin/Boolean|): R|kotlin/Unit| {
}
public final fun test_5(x: R|A?|): R|kotlin/Unit| {
R|<local>/x|?.{ $subj$.R|kotlin/let|<R|A|, R|kotlin/Nothing|>(<L> = let@fun <anonymous>(it: R|A|): R|kotlin/Nothing| <inline=Inline, kind=EXACTLY_ONCE> {
^test_5 Unit
}
) }?.{ $subj$.R|/boo|(R|<local>/x|.R|/A.bool|()) }
R|<local>/x|.<Inapplicable(UNSAFE_CALL): /A.id>#()
}