KT-13884 Exception "Invalid root block PSI element" on replacing trivial when-expression to if

#KT-13884 Fixed
This commit is contained in:
Valentin Kipyatkov
2016-10-04 20:44:09 +03:00
parent 597cd04831
commit c06e2d994e
4 changed files with 29 additions and 6 deletions
@@ -33,6 +33,7 @@ class WhenToIfIntention : SelfTargetingRangeIntention<KtWhenExpression>(KtWhenEx
if (entries.isEmpty()) return null
val lastEntry = entries.last()
if (entries.any { it != lastEntry && it.isElse }) return null
if (entries.all { it.isElse }) return null // 'when' with only 'else' branch is not supported
return element.whenKeyword.textRange
}