Add test for smart cast on a value bound to when subject variable
E.g.:
when (val y = x?.foo()) {
null -> ...
else -> ... // 'x' is also non-null here
}
This commit is contained in:
+9
@@ -0,0 +1,9 @@
|
||||
// !LANGUAGE: +VariableDeclarationInWhenSubject
|
||||
|
||||
fun foo(s1: String, s2: String) = s1 + s2
|
||||
|
||||
fun test(x: Any?) =
|
||||
when (val y = x?.toString()) {
|
||||
null -> "null"
|
||||
else -> foo(<!DEBUG_INFO_SMARTCAST!>x<!>.toString(), <!DEBUG_INFO_SMARTCAST!>y<!>)
|
||||
}
|
||||
+4
@@ -0,0 +1,4 @@
|
||||
package
|
||||
|
||||
public fun foo(/*0*/ s1: kotlin.String, /*1*/ s2: kotlin.String): kotlin.String
|
||||
public fun test(/*0*/ x: kotlin.Any?): kotlin.String
|
||||
Reference in New Issue
Block a user