Don't register safe cast type info for unstable values

Important: to be removed in 1.3
So #KT-20752 Fixed
This commit is contained in:
Mikhail Glukhikh
2017-10-13 14:43:42 +03:00
committed by Mikhail Glukhikh
parent 8ae3dbdcfc
commit a55c6f0c95
7 changed files with 162 additions and 6 deletions
@@ -0,0 +1,40 @@
// !LANGUAGE: +BooleanElvisBoundSmartCasts
// See KT-20752
class Unstable {
val first: String? get() = null
}
class StringList {
fun remove(s: String) = s
}
fun StringList.remove(s: String?) = s ?: ""
fun String.isEmpty() = this == ""
fun foo(list: StringList, arg: Unstable) {
list.remove(arg.first)
if (arg.first?.isEmpty() ?: false) {
// Ideally should have smart cast impossible here
list.remove(<!SMARTCAST_IMPOSSIBLE!>arg.first<!>)
}
}
class UnstableBoolean {
val first: Boolean? get() = null
}
class BooleanList {
fun remove(b: Boolean) = b
}
fun BooleanList.remove(b: Boolean?) = b ?: false
fun bar(list: BooleanList, arg: UnstableBoolean) {
list.remove(arg.first)
if (arg.first ?: false) {
// Ideally should have smart cast impossible here
list.remove(<!SMARTCAST_IMPOSSIBLE!>arg.first<!>)
}
}