@@ -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 ) {
@@ -1756,6 +1758,12 @@ open class KotlinFileExtractor(
1756
1758
else -> false
1757
1759
}
1758
1760
1761
+ private fun isGenericArrayType (typeName : String ) =
1762
+ when (typeName) {
1763
+ " Array" -> true
1764
+ else -> false
1765
+ }
1766
+
1759
1767
private fun extractCall (c : IrCall , callable : Label <out DbCallable >, stmtExprParent : StmtExprParent ) {
1760
1768
with (" call" , c) {
1761
1769
val target = tryReplaceSyntheticFunction(c.symbol.owner)
@@ -2178,7 +2186,19 @@ open class KotlinFileExtractor(
2178
2186
}
2179
2187
}
2180
2188
isFunction(target, " kotlin" , " (some array type)" , { isArrayType(it) }, " iterator" ) -> {
2181
- findTopLevelFunctionOrWarn(" kotlin.jvm.internal.iterator" , " kotlin.jvm.internal.ArrayIteratorKt" , c)?.let { iteratorFn ->
2189
+ val parentClass = target.parent
2190
+ if (parentClass !is IrClass ) {
2191
+ logger.errorElement(" Iterator parent is not a class" , c)
2192
+ return
2193
+ }
2194
+
2195
+ var typeFilter = if (isGenericArrayType(parentClass.name.asString())) {
2196
+ " kotlin.jvm.internal.ArrayIteratorKt"
2197
+ } else {
2198
+ " kotlin.jvm.internal.ArrayIteratorsKt"
2199
+ }
2200
+
2201
+ findTopLevelFunctionOrWarn(" kotlin.jvm.internal.iterator" , typeFilter, arrayOf(parentClass.kotlinFqName.asString()), c)?.let { iteratorFn ->
2182
2202
val dispatchReceiver = c.dispatchReceiver
2183
2203
if (dispatchReceiver == null ) {
2184
2204
logger.errorElement(" No dispatch receiver found for array iterator call" , c)
0 commit comments