JVM IR: Fix mangling of @JvmStatic internal function in companion objects

This commit is contained in:
Steven Schäfer
2020-05-18 16:22:18 +02:00
committed by Alexander Udalov
parent 2d0445ebaa
commit 933440dc63
4 changed files with 28 additions and 1 deletions
@@ -21,6 +21,7 @@ import org.jetbrains.kotlin.backend.jvm.ir.copyCorrespondingPropertyFrom
import org.jetbrains.kotlin.backend.jvm.ir.isInCurrentModule
import org.jetbrains.kotlin.backend.jvm.ir.replaceThisByStaticReference
import org.jetbrains.kotlin.descriptors.Modality
import org.jetbrains.kotlin.descriptors.Visibilities
import org.jetbrains.kotlin.ir.builders.declarations.addFunction
import org.jetbrains.kotlin.ir.builders.declarations.buildFunWithDescriptorForInlining
import org.jetbrains.kotlin.ir.builders.irCall
@@ -99,7 +100,9 @@ private class CompanionObjectJvmStaticLowering(val context: JvmBackendContext) :
// so we do not have a property to link it up to. Therefore, we compute the right name now.
name = Name.identifier(context.methodSignatureMapper.mapFunctionName(target))
modality = if (isInterface) Modality.OPEN else target.modality
visibility = target.visibility
// Since we already mangle the name above we need to reset internal visibilities to public in order
// to avoid mangling the same name twice.
visibility = if (target.visibility == Visibilities.INTERNAL) Visibilities.PUBLIC else target.visibility
isSuspend = target.isSuspend
}.apply {
copyTypeParametersFrom(target)