Introduce separate callee expression for when with subject variable
'Subject.Error' is redundant. 'Subject.None' can be an object. 'Subject#dataFlowValue' can be a lateinit property. TODO: fix - parsing local extension properties in 'when' subject - parsing destructuring declarations in 'when' subject - non-completed calls in nested 'when' with subject variable - non-completed calls for subject variable in 'in' pattern
This commit is contained in:
+20
-4
@@ -2,10 +2,26 @@
|
||||
// !DIAGNOSTICS: -UNUSED_VARIABLE -UNUSED_PARAMETER
|
||||
|
||||
fun foo(): Any = 42
|
||||
fun useInt(i: Int) {}
|
||||
|
||||
fun test(y: Any) {
|
||||
val z = when (val <!NAME_SHADOWING!>y<!> = foo()) {
|
||||
42 -> "Magic: $y"
|
||||
else -> "Not magic: $y"
|
||||
fun testShadowingParameter(y: Any) {
|
||||
when (val <!NAME_SHADOWING!>y<!> = foo()) {
|
||||
else -> {}
|
||||
}
|
||||
}
|
||||
|
||||
fun testShadowedInWhenBody(x: Any) {
|
||||
when (val y = x) {
|
||||
is String -> {
|
||||
val <!NAME_SHADOWING!>y<!> = <!DEBUG_INFO_SMARTCAST!>y<!>.length
|
||||
useInt(y)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
fun testShadowinLocalVariable() {
|
||||
val y = foo()
|
||||
when (val <!NAME_SHADOWING!>y<!> = foo()) {
|
||||
else -> {}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user