"!is" in when case
This commit is contained in:
+9
-2
@@ -254,8 +254,15 @@ private class Processor(
|
||||
}
|
||||
|
||||
is KtWhenConditionIsPattern -> {
|
||||
//TODO: smart cast is possible outside of when or inside other branches!
|
||||
usePlainSearch(typeRefParent.parent as KtWhenEntry)
|
||||
val whenEntry = typeRefParent.parent as KtWhenEntry
|
||||
if (typeRefParent.isNegated) {
|
||||
val whenExpression = whenEntry.parent as KtWhenExpression
|
||||
val entriesAfter = whenExpression.entries.dropWhile { it != whenEntry }.drop(1)
|
||||
entriesAfter.forEach { usePlainSearch(it) }
|
||||
}
|
||||
else {
|
||||
usePlainSearch(whenEntry)
|
||||
}
|
||||
return true
|
||||
}
|
||||
|
||||
|
||||
@@ -33,7 +33,7 @@ fun y(o: Any) {
|
||||
val (x, y) = list[0]
|
||||
}
|
||||
|
||||
fun z(o: Any) {
|
||||
fun when1(o: Any) {
|
||||
when (o) {
|
||||
is A -> {
|
||||
val (x, y) = o
|
||||
@@ -44,3 +44,13 @@ fun z(o: Any) {
|
||||
else -> return
|
||||
}
|
||||
}
|
||||
|
||||
fun when2(o: Any) {
|
||||
when (o) {
|
||||
!is A -> { }
|
||||
|
||||
else -> {
|
||||
val (x, y) = o
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -12,6 +12,7 @@
|
||||
[dataClass.2.kt] Value read 33 val (x, y) = list[0]
|
||||
[dataClass.2.kt] Value read 39 val (x, y) = o
|
||||
[dataClass.2.kt] Value read 5 a.n
|
||||
[dataClass.2.kt] Value read 53 val (x, y) = o
|
||||
[dataClass.2.kt] Value read 8 val (x, y, z) = a
|
||||
[dataClass.2.kt] Value read 9 val (x1, y1, z1) = f()
|
||||
[dataClass.3.kt] Value read 12 val (x, y, z) = a
|
||||
|
||||
Reference in New Issue
Block a user