Skip to content

Commit 56ef173

Browse files
committed
Kotlin: fix KFunctionX.invoke extraction
1 parent fdf3488 commit 56ef173

File tree

2 files changed

+8
-1
lines changed

2 files changed

+8
-1
lines changed

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

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1318,6 +1318,14 @@ open class KotlinFileExtractor(
13181318
val receiverClass = receiverType.classifier.owner as? IrClass ?: return listOf()
13191319
val ancestorTypes = ArrayList<IrSimpleType>()
13201320

1321+
// KFunctionX doesn't implement FunctionX on versions before 1.7.0:
1322+
if ((callTarget.name.asString() == "invoke") &&
1323+
(receiverClass.fqNameWhenAvailable?.asString()?.startsWith("kotlin.reflect.KFunction") == true) &&
1324+
(callTarget.parentClassOrNull?.fqNameWhenAvailable?.asString()?.startsWith("kotlin.Function") == true)
1325+
) {
1326+
return receiverType.arguments
1327+
}
1328+
13211329
// Populate ancestorTypes with the path from receiverType's class to its ancestor, callTarget's declaring type.
13221330
fun walkFrom(c: IrClass): Boolean {
13231331
if(declaringType == c)
Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +0,0 @@
1-
| app/src/main/kotlin/testProject/App.kt:0:0:0:0 | Failed to find a class declaring invoke starting at KFunction2 |

0 commit comments

Comments
 (0)