Skip to content

Commit ed04bec

Browse files
authored
Merge pull request #10274 from igfoo/igfoo/extractCall
Kotlin: Remove a cast in array iterator call extraction
2 parents 3195404 + a568765 commit ed04bec

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
@@ -2184,13 +2184,18 @@ open class KotlinFileExtractor(
21842184
if (dispatchReceiver == null) {
21852185
logger.errorElement("No dispatch receiver found for array iterator call", c)
21862186
} else {
2187-
val typeArgs = (dispatchReceiver.type as IrSimpleType).arguments.map {
2188-
when(it) {
2189-
is IrTypeProjection -> it.type
2190-
else -> pluginContext.irBuiltIns.anyNType
2187+
val drType = dispatchReceiver.type
2188+
if (drType !is IrSimpleType) {
2189+
logger.errorElement("Dispatch receiver with unexpected type rep found for array iterator call: ${drType.javaClass}", c)
2190+
} else {
2191+
val typeArgs = drType.arguments.map {
2192+
when(it) {
2193+
is IrTypeProjection -> it.type
2194+
else -> pluginContext.irBuiltIns.anyNType
2195+
}
21912196
}
2197+
extractRawMethodAccess(iteratorFn, c, callable, parent, idx, enclosingStmt, listOf(c.dispatchReceiver), null, null, typeArgs)
21922198
}
2193-
extractRawMethodAccess(iteratorFn, c, callable, parent, idx, enclosingStmt, listOf(c.dispatchReceiver), null, null, typeArgs)
21942199
}
21952200
}
21962201
}

0 commit comments

Comments
 (0)