[Test] Add diagnostic tests for smartcast in K2

List of issues:
KT-28806, KT-7186, KT-22997, KT-1982, KT-22996, KT-54443, KT-37308, KT-37115, KT-4113, KT-25747, KT-24779
This commit is contained in:
Aleksandra.Arsenteva
2023-11-28 16:50:14 +03:00
committed by Space Team
parent 48072c822b
commit c6b32200df
27 changed files with 3802 additions and 0 deletions
@@ -0,0 +1,29 @@
// ISSUE: KT-54443
// WITH_STDLIB
class A {
val b: Int? = 1
val e: C? = C()
}
class C {
val d: Int? = 2
}
fun test(a: A?) {
require(a?.b != null)
a.b.inc()
}
fun test2(a: A?){
require(a?.e?.d != null)
var k: C = a.e
var k2: Int = a.e.d
var k3: Int? = a.b
}
fun test3(a:A?){
val t = (a?.b != null)
require(t)
a.b.inc()
}
@@ -0,0 +1,29 @@
// ISSUE: KT-54443
// WITH_STDLIB
class A {
val b: Int? = 1
val e: C? = C()
}
class C {
val d: Int? = 2
}
fun test(a: A?) {
require(a?.b != null)
a<!UNSAFE_CALL!>.<!>b<!UNSAFE_CALL!>.<!>inc()
}
fun test2(a: A?){
require(a?.e?.d != null)
var k: C = <!TYPE_MISMATCH!>a<!UNSAFE_CALL!>.<!>e<!>
var k2: Int = <!TYPE_MISMATCH!>a<!UNSAFE_CALL!>.<!>e<!UNSAFE_CALL!>.<!>d<!>
var k3: Int? = a<!UNSAFE_CALL!>.<!>b
}
fun test3(a:A?){
val t = (a?.b != null)
require(t)
a<!UNSAFE_CALL!>.<!>b<!UNSAFE_CALL!>.<!>inc()
}