JVM IR: Fix visibility of protected/private functions with reified types
This commit is contained in:
committed by
Alexander Udalov
parent
dad10e94aa
commit
98a9e142e8
+1
-5
@@ -180,11 +180,7 @@ private fun IrDeclarationWithVisibility.specialCaseVisibility(kind: OwnerKind?):
|
||||
return Opcodes.ACC_PRIVATE
|
||||
}
|
||||
|
||||
if (this is IrFunction && (isReifiable() || isBridge())) {
|
||||
return Opcodes.ACC_PUBLIC
|
||||
}
|
||||
|
||||
if (isEffectivelyInlineOnly()) {
|
||||
if (isInlineOnlyPrivateInBytecode() || isInlineOnlyPropertyAccessor()) {
|
||||
return Opcodes.ACC_PRIVATE
|
||||
}
|
||||
|
||||
|
||||
@@ -417,31 +417,12 @@ internal class BridgeLowering(val context: JvmBackendContext) : FileLoweringPass
|
||||
overriddenSymbols = irFunction.overriddenSymbols.toList()
|
||||
}
|
||||
|
||||
private fun getBridgeVisibility(bridge: Bridge): DescriptorVisibility {
|
||||
// Even though kotlin.Cloneable#clone() is protected, corresponding bridge is 'public' in JVM.
|
||||
if (bridge.overridden.name.asString() == "clone" &&
|
||||
bridge.overridden.parentAsClass.hasEqualFqName(StandardNames.FqNames.cloneable.toSafe())
|
||||
) {
|
||||
return DescriptorVisibilities.PUBLIC
|
||||
}
|
||||
|
||||
val overriddenVisibility = bridge.overridden.visibility
|
||||
// Internal functions can be overridden by non-internal functions, which changes their names since the names of internal
|
||||
// functions are mangled. In order to avoid mangling the name twice we reset the visibility for bridges to internal
|
||||
// functions to public and use the mangled name directly.
|
||||
return if (overriddenVisibility == DescriptorVisibilities.INTERNAL)
|
||||
DescriptorVisibilities.PUBLIC
|
||||
else
|
||||
overriddenVisibility
|
||||
}
|
||||
|
||||
private fun IrClass.addBridge(bridge: Bridge, target: IrSimpleFunction): IrSimpleFunction =
|
||||
addFunction {
|
||||
startOffset = this@addBridge.startOffset
|
||||
endOffset = this@addBridge.startOffset
|
||||
modality = Modality.OPEN
|
||||
origin = IrDeclarationOrigin.BRIDGE
|
||||
visibility = getBridgeVisibility(bridge)
|
||||
name = Name.identifier(bridge.signature.name)
|
||||
returnType = bridge.overridden.returnType.eraseTypeParameters()
|
||||
isSuspend = bridge.overridden.isSuspend
|
||||
|
||||
Reference in New Issue
Block a user