[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,35 @@
// ISSUE: KT-25747
fun test1() {
val nullableString: String? = ""
val savedSmartCastResult = nullableString != null
if (savedSmartCastResult) {
nullableString<!UNSAFE_CALL!>.<!>length
}
}
fun test2() {
var nullableAny: Any? = ""
val savedSmartCastResult = nullableAny is String
nullableAny = 10
if (savedSmartCastResult) {
nullableAny.<!UNRESOLVED_REFERENCE!>length<!>
}
}
class A {
val a: String? = ""
}
fun test3(a: A){
val savedSmartCastResult = a.a != null
if(savedSmartCastResult) {
a.a<!UNSAFE_CALL!>.<!>length
}
}
fun test4() {
val nullableAny: Any? = ""
val savedSmartCastResult = (nullableAny!= null && nullableAny is String?)
if(savedSmartCastResult) {
nullableAny.<!UNRESOLVED_REFERENCE!>length<!>
}
}