"!is" in when case

This commit is contained in:
Valentin Kipyatkov
2016-08-26 19:10:36 +03:00
parent 5b3102058c
commit e00c8d6e05
3 changed files with 21 additions and 3 deletions
@@ -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
}