Skip to content

Commit f9d65e4

Browse files
committed
Use compiler-provided adapter functions when creating a function reference
1 parent 4c63237 commit f9d65e4

File tree

4 files changed

+625
-8
lines changed

4 files changed

+625
-8
lines changed

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

Lines changed: 10 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -4389,10 +4389,16 @@ open class KotlinFileExtractor(
43894389
callable: Label<out DbCallable>
43904390
) {
43914391
with("function reference", functionReferenceExpr) {
4392-
val target = functionReferenceExpr.reflectionTarget ?: run {
4393-
logger.warnElement("Expected to find reflection target for function reference. Using underlying symbol instead.", functionReferenceExpr)
4394-
functionReferenceExpr.symbol
4395-
}
4392+
val target =
4393+
if (functionReferenceExpr.origin == IrStatementOrigin.ADAPTED_FUNCTION_REFERENCE)
4394+
// For an adaptation (e.g. to adjust the number or type of arguments or results), the symbol field points at the adapter while `.reflectionTarget` points at the source-level target.
4395+
functionReferenceExpr.symbol
4396+
else
4397+
// TODO: Consider whether we could always target the symbol
4398+
functionReferenceExpr.reflectionTarget ?: run {
4399+
logger.warnElement("Expected to find reflection target for function reference. Using underlying symbol instead.", functionReferenceExpr)
4400+
functionReferenceExpr.symbol
4401+
}
43964402

43974403
/*
43984404
* Extract generated class:

0 commit comments

Comments
 (0)