Treat internals as publics for fake override construction

This commit is contained in:
Alexander Gorshenev
2020-06-24 22:38:59 +03:00
parent e61960f333
commit e08b800eb9
2 changed files with 2 additions and 31 deletions
@@ -194,7 +194,7 @@ class IrOverridingUtil(
toFilter: Collection<IrOverridableMember>
): Collection<IrOverridableMember> {
return toFilter.filter { member: IrOverridableMember ->
!Visibilities.isPrivate(member.visibility) && isVisibleIgnoringReceiver(member.original, current)
!Visibilities.isPrivate(member.visibility)
}
}
@@ -11,40 +11,11 @@ import org.jetbrains.kotlin.resolve.scopes.receivers.ReceiverValue
// The contents of this file is from VisibilityUtil.kt adapted to IR.
// TODO: The code would better be commonized for descriptors, ir and fir.
private fun findInvisibleMember(
receiver: ReceiverValue?,
what: IrDeclarationWithVisibility,
from: IrDeclaration
): IrDeclarationWithVisibility? {
// TODO: We need the proper code for IR,
// but that requires many of Visibilities.java available in IR.
// So for now we stick to a quick hack serving the needs
// of fake override construction algorithm.
val parentsWithSelf = sequenceOf(what) + what.parents
parentsWithSelf.forEach {
if (it !is IrDeclarationWithVisibility) return null
if (it.visibility == Visibilities.INTERNAL &&
(from.module != it.module)
) {
return it
}
}
return null
}
fun isVisibleIgnoringReceiver(
what: IrDeclarationWithVisibility,
from: IrDeclaration
): Boolean {
return findInvisibleMember(Visibilities.ALWAYS_SUITABLE_RECEIVER, what, from) == null
}
fun isVisibleForOverride(
overriding: IrOverridableMember,
fromSuper: IrOverridableMember
): Boolean {
return !Visibilities.isPrivate((fromSuper as IrDeclarationWithVisibility).visibility) &&
isVisibleIgnoringReceiver(fromSuper, overriding)
return !Visibilities.isPrivate((fromSuper as IrDeclarationWithVisibility).visibility)
}
fun findMemberWithMaxVisibility(members: Collection<IrOverridableMember>): IrOverridableMember {