Make smart casts work with variable declared in when subject

This commit is contained in:
Dmitry Petrov
2017-10-20 16:30:57 +03:00
parent 1eeafc2d0e
commit 098d3eb235
6 changed files with 198 additions and 99 deletions
@@ -0,0 +1,8 @@
// !LANGUAGE: +VariableDeclarationInWhenSubject
fun test(x: Any?) =
when (val y = x) {
is String -> "String, length = ${<!DEBUG_INFO_SMARTCAST!>y<!>.length}"
null -> "Null"
else -> "Any, hashCode = ${<!DEBUG_INFO_SMARTCAST!>y<!>.hashCode()}"
}
@@ -0,0 +1,3 @@
package
public fun test(/*0*/ x: kotlin.Any?): kotlin.String