[FIR-TEST] Move analysis tests to separate module
This commit is contained in:
+60
@@ -0,0 +1,60 @@
|
||||
// !DUMP_CFG
|
||||
// ----------------- Stable -----------------
|
||||
|
||||
class A {
|
||||
fun foo(): Int = 1
|
||||
|
||||
val x: Int = 1
|
||||
|
||||
fun bar() {}
|
||||
}
|
||||
|
||||
fun test_1(a: A?) {
|
||||
val x = a?.x
|
||||
if (x != null) {
|
||||
a.bar() // Should be OK
|
||||
}
|
||||
}
|
||||
|
||||
fun test_2(a: A?) {
|
||||
val x = a?.foo()
|
||||
if (x != null) {
|
||||
a.bar() // Should be OK
|
||||
}
|
||||
}
|
||||
|
||||
fun test_3(x: Any?) {
|
||||
val a = x as? A ?: return
|
||||
a.foo() // Should be OK
|
||||
x.foo() // Should be OK
|
||||
}
|
||||
|
||||
// ----------------- Unstable -----------------
|
||||
|
||||
interface B {
|
||||
fun foo(): Int
|
||||
|
||||
val x: Int
|
||||
|
||||
fun bar()
|
||||
}
|
||||
|
||||
fun test_1(a: B?) {
|
||||
val x = a?.x
|
||||
if (x != null) {
|
||||
a.bar() // Should be OK
|
||||
}
|
||||
}
|
||||
|
||||
fun test_2(a: B?) {
|
||||
val x = a?.foo()
|
||||
if (x != null) {
|
||||
a.bar() // Should be OK
|
||||
}
|
||||
}
|
||||
|
||||
fun test_3(x: Any?) {
|
||||
val a = x as? B ?: return
|
||||
a.foo() // Should be OK
|
||||
x.foo() // Should be OK
|
||||
}
|
||||
Reference in New Issue
Block a user