Skip to content

Commit 4e15f5f

Browse files
committed
Fix extracted type arguments of kotlin.jvm.functions.FunctionN
Previously we accidentally extracted an argument type instead of the result type.
1 parent 102cdcd commit 4e15f5f

File tree

1 file changed

+3
-1
lines changed

1 file changed

+3
-1
lines changed

java/kotlin-extractor/src/main/kotlin/KotlinUsesExtractor.kt

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -253,10 +253,12 @@ open class KotlinUsesExtractor(
253253
val extractClass = substituteClass ?: c
254254

255255
// `KFunction1<T1,T2>` is substituted by `KFunction<T>`. The last type argument is the return type.
256+
// Similarly Function23 and above get replaced by kotlin.jvm.functions.FunctionN with only one type arg, the result type.
256257
// References to SomeGeneric<T1, T2, ...> where SomeGeneric is declared SomeGeneric<T1, T2, ...> are extracted
257258
// as if they were references to the unbound type SomeGeneric.
258259
val extractedTypeArgs = when {
259-
c.symbol.isKFunction() && typeArgs != null && typeArgs.isNotEmpty() -> listOf(typeArgs.last())
260+
extractClass.symbol.isKFunction() && typeArgs != null && typeArgs.isNotEmpty() -> listOf(typeArgs.last())
261+
extractClass.fqNameWhenAvailable == FqName("kotlin.jvm.functions.FunctionN") && typeArgs != null && typeArgs.isNotEmpty() -> listOf(typeArgs.last())
260262
typeArgs != null && isUnspecialised(c, typeArgs) -> listOf()
261263
else -> typeArgs
262264
}

0 commit comments

Comments
 (0)