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 {
|
fun KtWhenExpression.introduceSubject(): KtWhenExpression? {
|
||||||
val subject = getSubjectToIntroduce()!!
|
val subject = getSubjectToIntroduce() ?: return null
|
||||||
|
|
||||||
val commentSaver = CommentSaver(this, saveLineBreaks = true)
|
val commentSaver = CommentSaver(this, saveLineBreaks = true)
|
||||||
|
|
||||||
|
|||||||
+1
-1
@@ -192,7 +192,7 @@ class IfToWhenIntention : SelfTargetingRangeIntention<KtIfExpression>(KtIfExpres
|
|||||||
|
|
||||||
|
|
||||||
if (whenExpression.getSubjectToIntroduce() != null) {
|
if (whenExpression.getSubjectToIntroduce() != null) {
|
||||||
whenExpression = whenExpression.introduceSubject()
|
whenExpression = whenExpression.introduceSubject() ?: return
|
||||||
}
|
}
|
||||||
|
|
||||||
val result = ifExpression.replaced(whenExpression)
|
val result = ifExpression.replaced(whenExpression)
|
||||||
|
|||||||
+1
-1
@@ -334,7 +334,7 @@ private fun makeCall(
|
|||||||
val inlinableCall = controlFlow.outputValues.size <= 1
|
val inlinableCall = controlFlow.outputValues.size <= 1
|
||||||
val unboxingExpressions =
|
val unboxingExpressions =
|
||||||
if (inlinableCall) {
|
if (inlinableCall) {
|
||||||
controlFlow.outputValueBoxer.getUnboxingExpressions(callText!!)
|
controlFlow.outputValueBoxer.getUnboxingExpressions(callText ?: return)
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
val varNameValidator = NewDeclarationNameValidator(block, anchorInBlock, NewDeclarationNameValidator.Target.VARIABLES)
|
val varNameValidator = NewDeclarationNameValidator(block, anchorInBlock, NewDeclarationNameValidator.Target.VARIABLES)
|
||||||
|
|||||||
Reference in New Issue
Block a user