Fix KNPE in introduce when expression (EA-118718)
This commit is contained in:
+2
-2
@@ -98,8 +98,8 @@ private fun KtExpression?.getWhenConditionSubjectCandidate(): KtExpression? {
|
||||
}
|
||||
}
|
||||
|
||||
fun KtWhenExpression.introduceSubject(): KtWhenExpression {
|
||||
val subject = getSubjectToIntroduce()!!
|
||||
fun KtWhenExpression.introduceSubject(): KtWhenExpression? {
|
||||
val subject = getSubjectToIntroduce() ?: return null
|
||||
|
||||
val commentSaver = CommentSaver(this, saveLineBreaks = true)
|
||||
|
||||
|
||||
+1
-1
@@ -192,7 +192,7 @@ class IfToWhenIntention : SelfTargetingRangeIntention<KtIfExpression>(KtIfExpres
|
||||
|
||||
|
||||
if (whenExpression.getSubjectToIntroduce() != null) {
|
||||
whenExpression = whenExpression.introduceSubject()
|
||||
whenExpression = whenExpression.introduceSubject() ?: return
|
||||
}
|
||||
|
||||
val result = ifExpression.replaced(whenExpression)
|
||||
|
||||
+1
-1
@@ -334,7 +334,7 @@ private fun makeCall(
|
||||
val inlinableCall = controlFlow.outputValues.size <= 1
|
||||
val unboxingExpressions =
|
||||
if (inlinableCall) {
|
||||
controlFlow.outputValueBoxer.getUnboxingExpressions(callText!!)
|
||||
controlFlow.outputValueBoxer.getUnboxingExpressions(callText ?: return)
|
||||
}
|
||||
else {
|
||||
val varNameValidator = NewDeclarationNameValidator(block, anchorInBlock, NewDeclarationNameValidator.Target.VARIABLES)
|
||||
|
||||
Reference in New Issue
Block a user