diff --git a/compiler/fir/psi2fir/src/org/jetbrains/kotlin/fir/builder/ConversionUtils.kt b/compiler/fir/psi2fir/src/org/jetbrains/kotlin/fir/builder/ConversionUtils.kt index 733227130f6..9a4a74322e3 100644 --- a/compiler/fir/psi2fir/src/org/jetbrains/kotlin/fir/builder/ConversionUtils.kt +++ b/compiler/fir/psi2fir/src/org/jetbrains/kotlin/fir/builder/ConversionUtils.kt @@ -188,18 +188,15 @@ internal fun FirExpression.generateNotNullOrOther( ).apply { branches += FirWhenBranchImpl( session, psi, - FirOperatorCallImpl(session, psi, FirOperation.NOT_EQ).apply { + FirOperatorCallImpl(session, psi, FirOperation.EQ).apply { arguments += subjectExpression arguments += FirConstExpressionImpl(session, psi, IrConstKind.Null, null) }, - FirSingleExpressionBlock( - session, - generateAccessExpression(session, psi, subjectName) - ) + FirSingleExpressionBlock(session, other) ) branches += FirWhenBranchImpl( session, other.psi, FirElseIfTrueCondition(session, psi), - FirSingleExpressionBlock(session, other) + FirSingleExpressionBlock(session, generateAccessExpression(session, psi, subjectName)) ) } } diff --git a/compiler/fir/psi2fir/testData/rawBuilder/expressions/nullability.txt b/compiler/fir/psi2fir/testData/rawBuilder/expressions/nullability.txt index 4f49359450f..19d62fdd6eb 100644 --- a/compiler/fir/psi2fir/testData/rawBuilder/expressions/nullability.txt +++ b/compiler/fir/psi2fir/testData/rawBuilder/expressions/nullability.txt @@ -1,22 +1,22 @@ FILE: nullability.kt public? final? fun orFourtyTwo(arg: Int?): { ^orFourtyTwo when (lval : = arg#) { - !=($subj$, Null(null)) -> { - # + ==($subj$, Null(null)) -> { + Int(42) } else -> { - Int(42) + # } } } public? final? fun bang(arg: Int?): { ^bang when (lval : = arg#) { - !=($subj$, Null(null)) -> { - # + ==($subj$, Null(null)) -> { + throw KotlinNullPointerException#() } else -> { - throw KotlinNullPointerException#() + # } }