Kotlin: fix KFunctionX.invoke extraction

This commit is contained in:
Tamas Vajk
2022-09-08 10:48:21 +02:00
parent fdf3488500
commit 56ef1739a3
2 changed files with 8 additions and 1 deletions

View File

@@ -1318,6 +1318,14 @@ open class KotlinFileExtractor(
val receiverClass = receiverType.classifier.owner as? IrClass ?: return listOf()
val ancestorTypes = ArrayList<IrSimpleType>()
// KFunctionX doesn't implement FunctionX on versions before 1.7.0:
if ((callTarget.name.asString() == "invoke") &&
(receiverClass.fqNameWhenAvailable?.asString()?.startsWith("kotlin.reflect.KFunction") == true) &&
(callTarget.parentClassOrNull?.fqNameWhenAvailable?.asString()?.startsWith("kotlin.Function") == true)
) {
return receiverType.arguments
}
// Populate ancestorTypes with the path from receiverType's class to its ancestor, callTarget's declaring type.
fun walkFrom(c: IrClass): Boolean {
if(declaringType == c)