Make EffectiveVisibility methods take typeContext instead initializing it in constructor

This is needed to reuse EffectiveVisibility in FIR, because typeContext
  in it is used to call `isSubtypeOf`, and in FIR it's required to use
  context from use site session (to see all declaration which are
   available in module)
This commit is contained in:
Dmitriy Novozhilov
2021-04-02 14:48:03 +03:00
committed by TeamCityServer
parent d7cd9e4c44
commit 220f8a9169
3 changed files with 123 additions and 97 deletions
@@ -8,6 +8,7 @@ package org.jetbrains.kotlin.descriptors
import org.jetbrains.kotlin.descriptors.EffectiveVisibility.Permissiveness import org.jetbrains.kotlin.descriptors.EffectiveVisibility.Permissiveness
import org.jetbrains.kotlin.types.AbstractTypeChecker import org.jetbrains.kotlin.types.AbstractTypeChecker
import org.jetbrains.kotlin.types.AbstractTypeCheckerContext import org.jetbrains.kotlin.types.AbstractTypeCheckerContext
import org.jetbrains.kotlin.types.model.TypeCheckerProviderContext
import org.jetbrains.kotlin.types.model.TypeConstructorMarker import org.jetbrains.kotlin.types.model.TypeConstructorMarker
sealed class EffectiveVisibility(val name: String, val publicApi: Boolean = false, val privateApi: Boolean = false) { sealed class EffectiveVisibility(val name: String, val publicApi: Boolean = false, val privateApi: Boolean = false) {
@@ -27,7 +28,7 @@ sealed class EffectiveVisibility(val name: String, val publicApi: Boolean = fals
object Private : EffectiveVisibility("private", privateApi = true) { object Private : EffectiveVisibility("private", privateApi = true) {
override fun relation(other: EffectiveVisibility): Permissiveness = override fun relation(other: EffectiveVisibility, typeCheckerContextProvider: TypeCheckerProviderContext): Permissiveness =
if (this == other || Local == other) Permissiveness.SAME else Permissiveness.LESS if (this == other || Local == other) Permissiveness.SAME else Permissiveness.LESS
override fun toVisibility(): Visibility = Visibilities.Private override fun toVisibility(): Visibility = Visibilities.Private
@@ -35,14 +36,14 @@ sealed class EffectiveVisibility(val name: String, val publicApi: Boolean = fals
// Effectively same as Private // Effectively same as Private
object Local : EffectiveVisibility("local") { object Local : EffectiveVisibility("local") {
override fun relation(other: EffectiveVisibility): Permissiveness = override fun relation(other: EffectiveVisibility, typeCheckerContextProvider: TypeCheckerProviderContext): Permissiveness =
if (this == other || Private == other) Permissiveness.SAME else Permissiveness.LESS if (this == other || Private == other) Permissiveness.SAME else Permissiveness.LESS
override fun toVisibility(): Visibility = Visibilities.Local override fun toVisibility(): Visibility = Visibilities.Local
} }
object Public : EffectiveVisibility("public", publicApi = true) { object Public : EffectiveVisibility("public", publicApi = true) {
override fun relation(other: EffectiveVisibility): Permissiveness = override fun relation(other: EffectiveVisibility, typeCheckerContextProvider: TypeCheckerProviderContext): Permissiveness =
if (this == other) Permissiveness.SAME else Permissiveness.MORE if (this == other) Permissiveness.SAME else Permissiveness.MORE
override fun toVisibility(): Visibility = Visibilities.Public override fun toVisibility(): Visibility = Visibilities.Public
@@ -51,19 +52,21 @@ sealed class EffectiveVisibility(val name: String, val publicApi: Boolean = fals
abstract class InternalOrPackage protected constructor(internal: Boolean) : EffectiveVisibility( abstract class InternalOrPackage protected constructor(internal: Boolean) : EffectiveVisibility(
if (internal) "internal" else "public/*package*/" if (internal) "internal" else "public/*package*/"
) { ) {
override fun relation(other: EffectiveVisibility): Permissiveness = when (other) { override fun relation(other: EffectiveVisibility, typeCheckerContextProvider: TypeCheckerProviderContext): Permissiveness =
Public -> Permissiveness.LESS when (other) {
Private, Local, InternalProtectedBound, is InternalProtected -> Permissiveness.MORE Public -> Permissiveness.LESS
is InternalOrPackage -> Permissiveness.SAME Private, Local, InternalProtectedBound, is InternalProtected -> Permissiveness.MORE
ProtectedBound, is Protected -> Permissiveness.UNKNOWN is InternalOrPackage -> Permissiveness.SAME
} ProtectedBound, is Protected -> Permissiveness.UNKNOWN
}
override fun lowerBound(other: EffectiveVisibility) = when (other) { override fun lowerBound(other: EffectiveVisibility, typeCheckerContextProvider: TypeCheckerProviderContext): EffectiveVisibility =
Public -> this when (other) {
Private, Local, InternalProtectedBound, is InternalOrPackage, is InternalProtected -> other Public -> this
is Protected -> InternalProtected(other.containerTypeConstructor, other.typeContext) Private, Local, InternalProtectedBound, is InternalOrPackage, is InternalProtected -> other
ProtectedBound -> InternalProtectedBound is Protected -> InternalProtected(other.containerTypeConstructor)
} ProtectedBound -> InternalProtectedBound
}
} }
object Internal : InternalOrPackage(true) { object Internal : InternalOrPackage(true) {
@@ -74,10 +77,7 @@ sealed class EffectiveVisibility(val name: String, val publicApi: Boolean = fals
override fun toVisibility(): Visibility = Visibilities.Private override fun toVisibility(): Visibility = Visibilities.Private
} }
class Protected( class Protected(val containerTypeConstructor: TypeConstructorMarker?) : EffectiveVisibility("protected", publicApi = true) {
val containerTypeConstructor: TypeConstructorMarker?,
val typeContext: AbstractTypeCheckerContext
) : EffectiveVisibility("protected", publicApi = true) {
override fun equals(other: Any?) = (other is Protected && containerTypeConstructor == other.containerTypeConstructor) override fun equals(other: Any?) = (other is Protected && containerTypeConstructor == other.containerTypeConstructor)
@@ -85,59 +85,66 @@ sealed class EffectiveVisibility(val name: String, val publicApi: Boolean = fals
override fun toString() = "${super.toString()} (in ${containerTypeConstructor ?: '?'})" override fun toString() = "${super.toString()} (in ${containerTypeConstructor ?: '?'})"
override fun relation(other: EffectiveVisibility): Permissiveness = when (other) { override fun relation(other: EffectiveVisibility, typeCheckerContextProvider: TypeCheckerProviderContext): Permissiveness =
Public -> Permissiveness.LESS when (other) {
Private, Local, ProtectedBound, InternalProtectedBound -> Permissiveness.MORE Public -> Permissiveness.LESS
is Protected -> containerRelation(containerTypeConstructor, other.containerTypeConstructor, typeContext) Private, Local, ProtectedBound, InternalProtectedBound -> Permissiveness.MORE
is InternalProtected -> when (containerRelation(containerTypeConstructor, other.containerTypeConstructor, typeContext)) { is Protected -> containerRelation(containerTypeConstructor, other.containerTypeConstructor, typeCheckerContextProvider)
// Protected never can be less permissive than internal & protected is InternalProtected -> when (containerRelation(
Permissiveness.SAME, Permissiveness.MORE -> Permissiveness.MORE containerTypeConstructor,
Permissiveness.UNKNOWN, Permissiveness.LESS -> Permissiveness.UNKNOWN other.containerTypeConstructor,
typeCheckerContextProvider
)) {
// Protected never can be less permissive than internal & protected
Permissiveness.SAME, Permissiveness.MORE -> Permissiveness.MORE
Permissiveness.UNKNOWN, Permissiveness.LESS -> Permissiveness.UNKNOWN
}
is InternalOrPackage -> Permissiveness.UNKNOWN
} }
is InternalOrPackage -> Permissiveness.UNKNOWN
}
override fun lowerBound(other: EffectiveVisibility) = when (other) { override fun lowerBound(other: EffectiveVisibility, typeCheckerContextProvider: TypeCheckerProviderContext): EffectiveVisibility =
Public -> this when (other) {
Private, Local, ProtectedBound, InternalProtectedBound -> other Public -> this
is Protected -> when (relation(other)) { Private, Local, ProtectedBound, InternalProtectedBound -> other
Permissiveness.SAME, Permissiveness.MORE -> this is Protected -> when (relation(other, typeCheckerContextProvider)) {
Permissiveness.LESS -> other Permissiveness.SAME, Permissiveness.MORE -> this
Permissiveness.UNKNOWN -> ProtectedBound Permissiveness.LESS -> other
Permissiveness.UNKNOWN -> ProtectedBound
}
is InternalProtected -> when (relation(other, typeCheckerContextProvider)) {
Permissiveness.LESS -> other
else -> InternalProtectedBound
}
is InternalOrPackage -> InternalProtected(containerTypeConstructor)
} }
is InternalProtected -> when (relation(other)) {
Permissiveness.LESS -> other
else -> InternalProtectedBound
}
is InternalOrPackage -> InternalProtected(containerTypeConstructor, typeContext)
}
override fun toVisibility(): Visibility = Visibilities.Protected override fun toVisibility(): Visibility = Visibilities.Protected
} }
// Lower bound for all protected visibilities // Lower bound for all protected visibilities
object ProtectedBound : EffectiveVisibility("protected (in different classes)", publicApi = true) { object ProtectedBound : EffectiveVisibility("protected (in different classes)", publicApi = true) {
override fun relation(other: EffectiveVisibility): Permissiveness = when (other) { override fun relation(other: EffectiveVisibility, typeCheckerContextProvider: TypeCheckerProviderContext): Permissiveness =
Public, is Protected -> Permissiveness.LESS when (other) {
Private, Local, InternalProtectedBound -> Permissiveness.MORE Public, is Protected -> Permissiveness.LESS
ProtectedBound -> Permissiveness.SAME Private, Local, InternalProtectedBound -> Permissiveness.MORE
is InternalOrPackage, is InternalProtected -> Permissiveness.UNKNOWN ProtectedBound -> Permissiveness.SAME
} is InternalOrPackage, is InternalProtected -> Permissiveness.UNKNOWN
}
override fun lowerBound(other: EffectiveVisibility) = when (other) { override fun lowerBound(other: EffectiveVisibility, typeCheckerContextProvider: TypeCheckerProviderContext): EffectiveVisibility =
Public, is Protected -> this when (other) {
Private, Local, ProtectedBound, InternalProtectedBound -> other Public, is Protected -> this
is InternalOrPackage, is InternalProtected -> InternalProtectedBound Private, Local, ProtectedBound, InternalProtectedBound -> other
} is InternalOrPackage, is InternalProtected -> InternalProtectedBound
}
override fun toVisibility(): Visibility = Visibilities.Protected override fun toVisibility(): Visibility = Visibilities.Protected
} }
// Lower bound for internal and protected(C) // Lower bound for internal and protected(C)
class InternalProtected( class InternalProtected(
val containerTypeConstructor: TypeConstructorMarker?, val containerTypeConstructor: TypeConstructorMarker?
val typeContext: AbstractTypeCheckerContext, ) : EffectiveVisibility("internal & protected", publicApi = false) {
) : EffectiveVisibility("internal & protected") {
override fun equals(other: Any?) = (other is InternalProtected && containerTypeConstructor == other.containerTypeConstructor) override fun equals(other: Any?) = (other is InternalProtected && containerTypeConstructor == other.containerTypeConstructor)
@@ -145,39 +152,50 @@ sealed class EffectiveVisibility(val name: String, val publicApi: Boolean = fals
override fun toString() = "${super.toString()} (in ${containerTypeConstructor ?: '?'})" override fun toString() = "${super.toString()} (in ${containerTypeConstructor ?: '?'})"
override fun relation(other: EffectiveVisibility): Permissiveness = when (other) { override fun relation(other: EffectiveVisibility, typeCheckerContextProvider: TypeCheckerProviderContext): Permissiveness =
Public, is InternalOrPackage -> Permissiveness.LESS when (other) {
Private, Local, InternalProtectedBound -> Permissiveness.MORE Public, is InternalOrPackage -> Permissiveness.LESS
is InternalProtected -> containerRelation(containerTypeConstructor, other.containerTypeConstructor, typeContext) Private, Local, InternalProtectedBound -> Permissiveness.MORE
is Protected -> when (containerRelation(containerTypeConstructor, other.containerTypeConstructor, typeContext)) { is InternalProtected -> containerRelation(
// Internal & protected never can be more permissive than just protected containerTypeConstructor,
Permissiveness.SAME, Permissiveness.LESS -> Permissiveness.LESS other.containerTypeConstructor,
Permissiveness.UNKNOWN, Permissiveness.MORE -> Permissiveness.UNKNOWN typeCheckerContextProvider
)
is Protected -> when (containerRelation(
containerTypeConstructor,
other.containerTypeConstructor,
typeCheckerContextProvider
)) {
// Internal & protected never can be more permissive than just protected
Permissiveness.SAME, Permissiveness.LESS -> Permissiveness.LESS
Permissiveness.UNKNOWN, Permissiveness.MORE -> Permissiveness.UNKNOWN
}
ProtectedBound -> Permissiveness.UNKNOWN
} }
ProtectedBound -> Permissiveness.UNKNOWN
}
override fun lowerBound(other: EffectiveVisibility) = when (other) { override fun lowerBound(other: EffectiveVisibility, typeCheckerContextProvider: TypeCheckerProviderContext): EffectiveVisibility =
Public, is InternalOrPackage -> this when (other) {
Private, Local, InternalProtectedBound -> other Public, is InternalOrPackage -> this
is Protected, is InternalProtected -> when (relation(other)) { Private, Local, InternalProtectedBound -> other
Permissiveness.SAME, Permissiveness.MORE -> this is Protected, is InternalProtected -> when (relation(other, typeCheckerContextProvider)) {
Permissiveness.LESS -> other Permissiveness.SAME, Permissiveness.MORE -> this
Permissiveness.UNKNOWN -> InternalProtectedBound Permissiveness.LESS -> other
Permissiveness.UNKNOWN -> InternalProtectedBound
}
ProtectedBound -> InternalProtectedBound
} }
ProtectedBound -> InternalProtectedBound
}
override fun toVisibility(): Visibility = Visibilities.Private override fun toVisibility(): Visibility = Visibilities.Private
} }
// Lower bound for internal and protected lower bound // Lower bound for internal and protected lower bound
object InternalProtectedBound : EffectiveVisibility("internal & protected (in different classes)") { object InternalProtectedBound : EffectiveVisibility("internal & protected (in different classes)") {
override fun relation(other: EffectiveVisibility): Permissiveness = when (other) { override fun relation(other: EffectiveVisibility, typeCheckerContextProvider: TypeCheckerProviderContext): Permissiveness =
Public, is Protected, is InternalProtected, ProtectedBound, is InternalOrPackage -> Permissiveness.LESS when (other) {
Private, Local -> Permissiveness.MORE Public, is Protected, is InternalProtected, ProtectedBound, is InternalOrPackage -> Permissiveness.LESS
InternalProtectedBound -> Permissiveness.SAME Private, Local -> Permissiveness.MORE
} InternalProtectedBound -> Permissiveness.SAME
}
override fun toVisibility(): Visibility = Visibilities.Private override fun toVisibility(): Visibility = Visibilities.Private
} }
@@ -189,15 +207,16 @@ sealed class EffectiveVisibility(val name: String, val publicApi: Boolean = fals
UNKNOWN UNKNOWN
} }
abstract fun relation(other: EffectiveVisibility): Permissiveness abstract fun relation(other: EffectiveVisibility, typeCheckerContextProvider: TypeCheckerProviderContext): Permissiveness
abstract fun toVisibility(): Visibility abstract fun toVisibility(): Visibility
open fun lowerBound(other: EffectiveVisibility) = when (relation(other)) { open fun lowerBound(other: EffectiveVisibility, typeCheckerContextProvider: TypeCheckerProviderContext): EffectiveVisibility =
Permissiveness.SAME, Permissiveness.LESS -> this when (relation(other, typeCheckerContextProvider)) {
Permissiveness.MORE -> other Permissiveness.SAME, Permissiveness.LESS -> this
Permissiveness.UNKNOWN -> Private Permissiveness.MORE -> other
} Permissiveness.UNKNOWN -> Private
}
} }
enum class RelationToType(val description: String) { enum class RelationToType(val description: String) {
@@ -217,14 +236,18 @@ enum class RelationToType(val description: String) {
internal fun containerRelation( internal fun containerRelation(
first: TypeConstructorMarker?, first: TypeConstructorMarker?,
second: TypeConstructorMarker?, second: TypeConstructorMarker?,
typeContext: AbstractTypeCheckerContext typeCheckerContextProvider: TypeCheckerProviderContext
): Permissiveness { ): Permissiveness {
return when { return when {
first == null || second == null -> Permissiveness.UNKNOWN first == null || second == null -> Permissiveness.UNKNOWN
first == second -> Permissiveness.SAME first == second -> Permissiveness.SAME
AbstractTypeChecker.isSubtypeOfClass(typeContext, first, second) -> Permissiveness.LESS AbstractTypeChecker.isSubtypeOfClass(typeCheckerContextProvider.createTypeCheckerContext(), first, second) -> Permissiveness.LESS
AbstractTypeChecker.isSubtypeOfClass(typeContext, second, first) -> Permissiveness.MORE AbstractTypeChecker.isSubtypeOfClass(typeCheckerContextProvider.createTypeCheckerContext(), second, first) -> Permissiveness.MORE
else -> Permissiveness.UNKNOWN else -> Permissiveness.UNKNOWN
} }
} }
private fun TypeCheckerProviderContext.createTypeCheckerContext(): AbstractTypeCheckerContext = newBaseTypeCheckerContext(
errorTypesEqualToAnything = false,
stubTypesEqualToAnything = true
)
@@ -7,7 +7,7 @@ package org.jetbrains.kotlin.descriptors
import org.jetbrains.kotlin.resolve.descriptorUtil.isPublishedApi import org.jetbrains.kotlin.resolve.descriptorUtil.isPublishedApi
import org.jetbrains.kotlin.types.KotlinType import org.jetbrains.kotlin.types.KotlinType
import org.jetbrains.kotlin.types.checker.ClassicTypeCheckerContext import org.jetbrains.kotlin.types.checker.SimpleClassicTypeSystemContext
fun EffectiveVisibility.toDescriptorVisibility(): DescriptorVisibility = DescriptorVisibilities.toDescriptorVisibility(toVisibility()) fun EffectiveVisibility.toDescriptorVisibility(): DescriptorVisibility = DescriptorVisibilities.toDescriptorVisibility(toVisibility())
@@ -22,8 +22,7 @@ private fun DescriptorVisibility.forVisibility(descriptor: DeclarationDescriptor
when (this) { when (this) {
DescriptorVisibilities.PRIVATE, DescriptorVisibilities.PRIVATE_TO_THIS, DescriptorVisibilities.INVISIBLE_FAKE -> EffectiveVisibility.Private DescriptorVisibilities.PRIVATE, DescriptorVisibilities.PRIVATE_TO_THIS, DescriptorVisibilities.INVISIBLE_FAKE -> EffectiveVisibility.Private
DescriptorVisibilities.PROTECTED -> EffectiveVisibility.Protected( DescriptorVisibilities.PROTECTED -> EffectiveVisibility.Protected(
(descriptor.containingDeclaration as? ClassDescriptor)?.defaultType?.constructor, (descriptor.containingDeclaration as? ClassDescriptor)?.defaultType?.constructor
ClassicTypeCheckerContext(errorTypeEqualsToAnything = false)
) )
DescriptorVisibilities.INTERNAL -> if (!checkPublishedApi || DescriptorVisibilities.INTERNAL -> if (!checkPublishedApi ||
!descriptor.isPublishedApi() !descriptor.isPublishedApi()
@@ -69,7 +68,7 @@ private fun KotlinType.dependentDescriptors(types: Set<KotlinType>, ownRelation:
private fun Set<DescriptorWithRelation>.leastPermissive(base: EffectiveVisibility): DescriptorWithRelation? { private fun Set<DescriptorWithRelation>.leastPermissive(base: EffectiveVisibility): DescriptorWithRelation? {
for (descriptorWithRelation in this) { for (descriptorWithRelation in this) {
val currentVisibility = descriptorWithRelation.effectiveVisibility() val currentVisibility = descriptorWithRelation.effectiveVisibility()
when (currentVisibility.relation(base)) { when (currentVisibility.relation(base, SimpleClassicTypeSystemContext)) {
EffectiveVisibility.Permissiveness.LESS, EffectiveVisibility.Permissiveness.UNKNOWN -> { EffectiveVisibility.Permissiveness.LESS, EffectiveVisibility.Permissiveness.UNKNOWN -> {
return descriptorWithRelation return descriptorWithRelation
} }
@@ -83,11 +82,14 @@ private fun Set<DescriptorWithRelation>.leastPermissive(base: EffectiveVisibilit
fun KotlinType.leastPermissiveDescriptor(base: EffectiveVisibility) = dependentDescriptors().leastPermissive(base) fun KotlinType.leastPermissiveDescriptor(base: EffectiveVisibility) = dependentDescriptors().leastPermissive(base)
fun DeclarationDescriptorWithVisibility.effectiveVisibility( fun DeclarationDescriptorWithVisibility.effectiveVisibility(
visibility: DescriptorVisibility = this.visibility, checkPublishedApi: Boolean = false visibility: DescriptorVisibility = this.visibility,
checkPublishedApi: Boolean = false
): EffectiveVisibility = ): EffectiveVisibility =
lowerBound( lowerBound(
visibility.effectiveVisibility(this, checkPublishedApi), visibility.effectiveVisibility(this, checkPublishedApi),
(this.containingDeclaration as? ClassDescriptor)?.effectiveVisibility(checkPublishedApi) ?: EffectiveVisibility.Public (this.containingDeclaration as? ClassDescriptor)?.effectiveVisibility(checkPublishedApi) ?: EffectiveVisibility.Public
) )
private fun lowerBound(first: EffectiveVisibility, second: EffectiveVisibility): EffectiveVisibility = first.lowerBound(second) private fun lowerBound(first: EffectiveVisibility, second: EffectiveVisibility): EffectiveVisibility {
return first.lowerBound(second, SimpleClassicTypeSystemContext)
}
@@ -18,8 +18,8 @@ package org.jetbrains.kotlin.idea.quickfix
import com.intellij.codeInsight.intention.IntentionAction import com.intellij.codeInsight.intention.IntentionAction
import org.jetbrains.kotlin.descriptors.* import org.jetbrains.kotlin.descriptors.*
import org.jetbrains.kotlin.descriptors.EffectiveVisibility.Permissiveness.LESS
import org.jetbrains.kotlin.descriptors.DescriptorVisibilities.* import org.jetbrains.kotlin.descriptors.DescriptorVisibilities.*
import org.jetbrains.kotlin.descriptors.EffectiveVisibility.Permissiveness.LESS
import org.jetbrains.kotlin.diagnostics.Diagnostic import org.jetbrains.kotlin.diagnostics.Diagnostic
import org.jetbrains.kotlin.diagnostics.DiagnosticFactory3 import org.jetbrains.kotlin.diagnostics.DiagnosticFactory3
import org.jetbrains.kotlin.idea.core.toDescriptor import org.jetbrains.kotlin.idea.core.toDescriptor
@@ -27,6 +27,7 @@ import org.jetbrains.kotlin.psi.KtDeclaration
import org.jetbrains.kotlin.psi.KtModifierListOwner import org.jetbrains.kotlin.psi.KtModifierListOwner
import org.jetbrains.kotlin.psi.psiUtil.getParentOfType import org.jetbrains.kotlin.psi.psiUtil.getParentOfType
import org.jetbrains.kotlin.resolve.DescriptorToSourceUtils import org.jetbrains.kotlin.resolve.DescriptorToSourceUtils
import org.jetbrains.kotlin.types.checker.SimpleClassicTypeSystemContext
import java.util.* import java.util.*
object ChangeVisibilityOnExposureFactory : KotlinIntentionActionsFactory() { object ChangeVisibilityOnExposureFactory : KotlinIntentionActionsFactory() {
@@ -58,7 +59,7 @@ object ChangeVisibilityOnExposureFactory : KotlinIntentionActionsFactory() {
DescriptorToSourceUtils.getSourceFromDescriptor(exposedDescriptor) as? KtModifierListOwner ?: return emptyList() DescriptorToSourceUtils.getSourceFromDescriptor(exposedDescriptor) as? KtModifierListOwner ?: return emptyList()
val exposedVisibility = exposedDiagnostic.c val exposedVisibility = exposedDiagnostic.c
val userVisibility = exposedDiagnostic.a val userVisibility = exposedDiagnostic.a
val (targetUserVisibility, targetExposedVisibility) = when (exposedVisibility.relation(userVisibility)) { val (targetUserVisibility, targetExposedVisibility) = when (exposedVisibility.relation(userVisibility, SimpleClassicTypeSystemContext)) {
LESS -> Pair(exposedVisibility.toDescriptorVisibility(), userVisibility.toDescriptorVisibility()) LESS -> Pair(exposedVisibility.toDescriptorVisibility(), userVisibility.toDescriptorVisibility())
else -> Pair(PRIVATE, PUBLIC) else -> Pair(PRIVATE, PUBLIC)
} }