Smart casts inside property chains like a?.b?.c.foo(a, b) are now handled correctly #KT-7290 Fixed

This commit is contained in:
Mikhail Glukhikh
2015-10-28 17:34:38 +03:00
parent 8be9be336f
commit 12103d19d2
4 changed files with 50 additions and 4 deletions
@@ -0,0 +1,14 @@
// See KT-7290
class MyClass(val x: String?)
fun foo(y: MyClass?): Int {
// x here is smartcast but y is not
val z = y?.x?.subSequence(0, <!DEBUG_INFO_SMARTCAST!><!DEBUG_INFO_SMARTCAST!>y<!>.x<!>.length)
// !! is necessary here
y!!.x
return z?.length ?: -1
}
fun bar(y: MyClass?) {
y?.x!!.length
// !! is necessary here
y!!.x
}