Skip to content

Commit 8fe59e7

Browse files
committed
Kotlin: Remove another not-null-expr
1 parent 01f27ea commit 8fe59e7

File tree

1 file changed

+10
-5
lines changed

1 file changed

+10
-5
lines changed

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

Lines changed: 10 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -2175,13 +2175,18 @@ open class KotlinFileExtractor(
21752175
}
21762176
isFunction(target, "kotlin", "(some array type)", { isArrayType(it) }, "iterator") && c.origin == IrStatementOrigin.FOR_LOOP_ITERATOR -> {
21772177
findTopLevelFunctionOrWarn("kotlin.jvm.internal.iterator", "kotlin.jvm.internal.ArrayIteratorKt", c)?.let { iteratorFn ->
2178-
val typeArgs = (c.dispatchReceiver!!.type as IrSimpleType).arguments.map {
2179-
when(it) {
2180-
is IrTypeProjection -> it.type
2181-
else -> pluginContext.irBuiltIns.anyNType
2178+
val dispatchReceiver = c.dispatchReceiver
2179+
if (dispatchReceiver == null) {
2180+
logger.errorElement("No dispatch receiver found for array iterator call", c)
2181+
} else {
2182+
val typeArgs = (dispatchReceiver.type as IrSimpleType).arguments.map {
2183+
when(it) {
2184+
is IrTypeProjection -> it.type
2185+
else -> pluginContext.irBuiltIns.anyNType
2186+
}
21822187
}
2188+
extractRawMethodAccess(iteratorFn, c, callable, parent, idx, enclosingStmt, listOf(c.dispatchReceiver), null, null, typeArgs)
21832189
}
2184-
extractRawMethodAccess(iteratorFn, c, callable, parent, idx, enclosingStmt, listOf(c.dispatchReceiver), null, null, typeArgs)
21852190
}
21862191
}
21872192
isFunction(target, "kotlin", "(some array type)", { isArrayType(it) }, "get") && c.origin == IrStatementOrigin.GET_ARRAY_ELEMENT -> {

0 commit comments

Comments
 (0)