From 9d3deb7e0e42793989631abd99dbb5966d2873f1 Mon Sep 17 00:00:00 2001 From: Dmitriy Dolovov Date: Mon, 17 Apr 2023 01:20:42 +0200 Subject: [PATCH] [PL] Fix: Don't count value arguments vs value parameters for external functions --- .../partial/PartiallyLinkedIrTreePatcher.kt | 21 +++++++++++++------ 1 file changed, 15 insertions(+), 6 deletions(-) diff --git a/compiler/ir/serialization.common/src/org/jetbrains/kotlin/backend/common/linkage/partial/PartiallyLinkedIrTreePatcher.kt b/compiler/ir/serialization.common/src/org/jetbrains/kotlin/backend/common/linkage/partial/PartiallyLinkedIrTreePatcher.kt index 7195610b665..aa06bc1025d 100644 --- a/compiler/ir/serialization.common/src/org/jetbrains/kotlin/backend/common/linkage/partial/PartiallyLinkedIrTreePatcher.kt +++ b/compiler/ir/serialization.common/src/org/jetbrains/kotlin/backend/common/linkage/partial/PartiallyLinkedIrTreePatcher.kt @@ -753,12 +753,21 @@ internal class PartiallyLinkedIrTreePatcher( 0 // Does not matter here. ) - if (this is IrFunctionReference) { - // Function references don't contain arguments. - return null - } else if (this is IrEnumConstructorCall && (function.parent as? IrClass)?.symbol == builtIns.enumClass) { - // This is a special case. IrEnumConstructorCall don't contain arguments. - return null + when (this) { + is IrFunctionAccessExpression -> { + if (function.isExternal) { + // External functions may have the default arguments declared in native implementations, + // which are not available from Kotlin. + return null + } else if (this is IrEnumConstructorCall && (function.parent as? IrClass)?.symbol == builtIns.enumClass) { + // This is a special case. IrEnumConstructorCall don't contain arguments. + return null + } + } + is IrFunctionReference -> { + // Function references don't contain arguments. + return null + } } // Default values are not kept in value parameters of fake override/delegated/override functions.