[NI] Improve CST algorithm to handle non-fixed variables

#KT-32456 Fixed
 #KT-32423 Fixed
 #KT-32818 Fixed
 #KT-33197 Fixed
This commit is contained in:
Mikhail Zarechenskiy
2019-08-28 01:23:18 +03:00
parent ba6648d535
commit ca8da22569
41 changed files with 605 additions and 81 deletions
@@ -0,0 +1,18 @@
// !LANGUAGE: +NewInference
// WITH_RUNTIME
// IGNORE_BACKEND: JS_IR
fun test(foo: MutableList<String>?): List<String> {
val bar = foo ?: listOf()
return bar
}
fun box(): String {
val a = test(null)
if (a.isNotEmpty()) return "Fail 1"
val b = test(mutableListOf("a"))
if (b.size != 1) return "Fail 2"
return "OK"
}
@@ -0,0 +1,23 @@
// WITH_RUNTIME
// IGNORE_BACKEND: JS_IR
fun test() {
fun returnMutableList(): MutableList<Int>? = null
fun returnsList(): List<Int>? = null
var mutableList: MutableList<Int>? = null
var list: List<Int>? = null
mutableListOf<Int>().addAll(returnMutableList() ?: emptyList<Int>())
mutableListOf<Int>().addAll(returnsList() ?: emptyList())
mutableListOf<Int>().addAll(list ?: emptyList())
mutableListOf<Int>().addAll(returnMutableList() ?: emptyList())
mutableListOf<Int>().addAll(mutableList ?: emptyList())
mutableListOf<Int>().addAll(null ?: emptyList())
}
fun box(): String {
test()
return "OK"
}