Skip to content

Commit b485706

Browse files
committed
Kotlin: Remove the last not-null-expressions
1 parent e4f66b8 commit b485706

File tree

1 file changed

+12
-2
lines changed

1 file changed

+12
-2
lines changed

java/kotlin-extractor/src/main/kotlin/KotlinFileExtractor.kt

Lines changed: 12 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2520,6 +2520,11 @@ open class KotlinFileExtractor(
25202520
indexVarDecl.initializer?.let { indexVarInitializer ->
25212521
(e.statements[2] as? IrCall)?.let { arraySetCall ->
25222522
if (isFunction(arraySetCall.symbol.owner, "kotlin", "(some array type)", { isArrayType(it) }, "set")) {
2523+
val updateRhs = arraySetCall.getValueArgument(1)
2524+
if (updateRhs == null) {
2525+
logger.errorElement("Update RHS not found", e)
2526+
return false
2527+
}
25232528
getUpdateInPlaceRHS(
25242529
e.origin, // Using e.origin not arraySetCall.origin here distinguishes a compiler-generated block from a user manually code that looks the same.
25252530
{ oldValue ->
@@ -2529,9 +2534,14 @@ open class KotlinFileExtractor(
25292534
receiverVal -> receiverVal.symbol.owner == arrayVarDecl.symbol.owner
25302535
} ?: false
25312536
},
2532-
arraySetCall.getValueArgument(1)!!
2537+
updateRhs
25332538
)?.let { updateRhs ->
2534-
val writeUpdateInPlaceExprFun = writeUpdateInPlaceExpr(e.origin!!)
2539+
val origin = e.origin
2540+
if (origin == null) {
2541+
logger.errorElement("No origin found", e)
2542+
return false
2543+
}
2544+
val writeUpdateInPlaceExprFun = writeUpdateInPlaceExpr(origin)
25352545
if (writeUpdateInPlaceExprFun == null) {
25362546
logger.errorElement("Unexpected origin", e)
25372547
return false

0 commit comments

Comments
 (0)