Use compiler-provided adapter functions when creating a function reference

This commit is contained in:
Chris Smowton
2022-10-13 15:29:49 +01:00
parent 4c63237ed1
commit f9d65e42dd
4 changed files with 625 additions and 8 deletions

View File

@@ -4389,10 +4389,16 @@ open class KotlinFileExtractor(
callable: Label<out DbCallable>
) {
with("function reference", functionReferenceExpr) {
val target = functionReferenceExpr.reflectionTarget ?: run {
logger.warnElement("Expected to find reflection target for function reference. Using underlying symbol instead.", functionReferenceExpr)
functionReferenceExpr.symbol
}
val target =
if (functionReferenceExpr.origin == IrStatementOrigin.ADAPTED_FUNCTION_REFERENCE)
// 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.
functionReferenceExpr.symbol
else
// TODO: Consider whether we could always target the symbol
functionReferenceExpr.reflectionTarget ?: run {
logger.warnElement("Expected to find reflection target for function reference. Using underlying symbol instead.", functionReferenceExpr)
functionReferenceExpr.symbol
}
/*
* Extract generated class: