Skip to content

Commit a568765

Browse files
committed
Kotlin: Remove a cast in array iterator call extraction
1 parent 4f7eb7b commit a568765

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
if (dispatchReceiver == null) {
21762176
logger.errorElement("No dispatch receiver found for array iterator call", c)
21772177
} else {
2178-
val typeArgs = (dispatchReceiver.type as IrSimpleType).arguments.map {
2179-
when(it) {
2180-
is IrTypeProjection -> it.type
2181-
else -> pluginContext.irBuiltIns.anyNType
2178+
val drType = dispatchReceiver.type
2179+
if (drType !is IrSimpleType) {
2180+
logger.errorElement("Dispatch receiver with unexpected type rep found for array iterator call: ${drType.javaClass}", c)
2181+
} else {
2182+
val typeArgs = drType.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
}

0 commit comments

Comments
 (0)