@@ -1600,11 +1600,13 @@ open class KotlinFileExtractor(
1600
1600
return result
1601
1601
}
1602
1602
1603
- private fun findTopLevelFunctionOrWarn (functionFilter : String , type : String , warnAgainstElement : IrElement ): IrFunction ? {
1603
+ private fun findTopLevelFunctionOrWarn (functionFilter : String , type : String , parameterTypes : Array < String >, warnAgainstElement : IrElement ): IrFunction ? {
1604
1604
1605
1605
val fn = pluginContext.referenceFunctions(FqName (functionFilter))
1606
- .firstOrNull { it.owner.parentClassOrNull?.fqNameWhenAvailable?.asString() == type }
1607
- ?.owner
1606
+ .firstOrNull { fnSymbol ->
1607
+ fnSymbol.owner.parentClassOrNull?.fqNameWhenAvailable?.asString() == type &&
1608
+ fnSymbol.owner.valueParameters.map { it.type.classFqName?.asString() }.toTypedArray() contentEquals parameterTypes
1609
+ }?.owner
1608
1610
1609
1611
if (fn != null ) {
1610
1612
if (fn.parentClassOrNull != null ) {
@@ -1754,6 +1756,12 @@ open class KotlinFileExtractor(
1754
1756
else -> false
1755
1757
}
1756
1758
1759
+ private fun isGenericArrayType (typeName : String ) =
1760
+ when (typeName) {
1761
+ " Array" -> true
1762
+ else -> false
1763
+ }
1764
+
1757
1765
private fun extractCall (c : IrCall , callable : Label <out DbCallable >, stmtExprParent : StmtExprParent ) {
1758
1766
with (" call" , c) {
1759
1767
val target = tryReplaceSyntheticFunction(c.symbol.owner)
@@ -2175,8 +2183,20 @@ open class KotlinFileExtractor(
2175
2183
extractRawMethodAccess(getter, c, callable, parent, idx, enclosingStmt, listOf (), null , ext, typeArguments)
2176
2184
}
2177
2185
}
2178
- isFunction(target, " kotlin" , " (some array type)" , { isArrayType(it) }, " iterator" ) && c.origin == IrStatementOrigin .FOR_LOOP_ITERATOR -> {
2179
- findTopLevelFunctionOrWarn(" kotlin.jvm.internal.iterator" , " kotlin.jvm.internal.ArrayIteratorKt" , c)?.let { iteratorFn ->
2186
+ isFunction(target, " kotlin" , " (some array type)" , { isArrayType(it) }, " iterator" ) -> {
2187
+ val parentClass = target.parent
2188
+ if (parentClass !is IrClass ) {
2189
+ logger.errorElement(" Iterator parent is not a class" , c)
2190
+ return
2191
+ }
2192
+
2193
+ var typeFilter = if (isGenericArrayType(parentClass.name.asString())) {
2194
+ " kotlin.jvm.internal.ArrayIteratorKt"
2195
+ } else {
2196
+ " kotlin.jvm.internal.ArrayIteratorsKt"
2197
+ }
2198
+
2199
+ findTopLevelFunctionOrWarn(" kotlin.jvm.internal.iterator" , typeFilter, arrayOf(parentClass.kotlinFqName.asString()), c)?.let { iteratorFn ->
2180
2200
val dispatchReceiver = c.dispatchReceiver
2181
2201
if (dispatchReceiver == null ) {
2182
2202
logger.errorElement(" No dispatch receiver found for array iterator call" , c)
0 commit comments