Merge pull request #10274 from igfoo/igfoo/extractCall

Kotlin: Remove a cast in array iterator call extraction
This commit is contained in:
Ian Lynagh
2022-09-02 13:26:10 +01:00
committed by GitHub

View File

@@ -2184,13 +2184,18 @@ open class KotlinFileExtractor(
if (dispatchReceiver == null) {
logger.errorElement("No dispatch receiver found for array iterator call", c)
} else {
val typeArgs = (dispatchReceiver.type as IrSimpleType).arguments.map {
when(it) {
is IrTypeProjection -> it.type
else -> pluginContext.irBuiltIns.anyNType
val drType = dispatchReceiver.type
if (drType !is IrSimpleType) {
logger.errorElement("Dispatch receiver with unexpected type rep found for array iterator call: ${drType.javaClass}", c)
} else {
val typeArgs = drType.arguments.map {
when(it) {
is IrTypeProjection -> it.type
else -> pluginContext.irBuiltIns.anyNType
}
}
extractRawMethodAccess(iteratorFn, c, callable, parent, idx, enclosingStmt, listOf(c.dispatchReceiver), null, null, typeArgs)
}
extractRawMethodAccess(iteratorFn, c, callable, parent, idx, enclosingStmt, listOf(c.dispatchReceiver), null, null, typeArgs)
}
}
}