Smart casts inside property chains like a?.b?.c.foo(a, b) are now handled correctly #KT-7290 Fixed
This commit is contained in:
@@ -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
|
||||
}
|
||||
@@ -0,0 +1,12 @@
|
||||
package
|
||||
|
||||
public fun bar(/*0*/ y: MyClass?): kotlin.Unit
|
||||
public fun foo(/*0*/ y: MyClass?): kotlin.Int
|
||||
|
||||
public final class MyClass {
|
||||
public constructor MyClass(/*0*/ x: kotlin.String?)
|
||||
public final val x: kotlin.String?
|
||||
public open override /*1*/ /*fake_override*/ fun equals(/*0*/ other: kotlin.Any?): kotlin.Boolean
|
||||
public open override /*1*/ /*fake_override*/ fun hashCode(): kotlin.Int
|
||||
public open override /*1*/ /*fake_override*/ fun toString(): kotlin.String
|
||||
}
|
||||
Reference in New Issue
Block a user