Rename EffectiveVisibility.Private to PrivateInClass
This commit is contained in:
@@ -26,29 +26,30 @@ sealed class EffectiveVisibility(val name: String, val publicApi: Boolean = fals
|
||||
// |
|
||||
// PrivateInFile
|
||||
// |
|
||||
// Private = Local
|
||||
// PrivateInClass = Local
|
||||
|
||||
|
||||
object Private : EffectiveVisibility("private", privateApi = true) {
|
||||
// Private class (interface) member
|
||||
object PrivateInClass : EffectiveVisibility("private-in-class", privateApi = true) {
|
||||
override fun relation(other: EffectiveVisibility, typeCheckerContextProvider: TypeCheckerProviderContext): Permissiveness =
|
||||
if (this == other || Local == other) Permissiveness.SAME else Permissiveness.LESS
|
||||
|
||||
override fun toVisibility(): Visibility = Visibilities.Private
|
||||
}
|
||||
|
||||
// Effectively same as Private
|
||||
// Effectively same as PrivateInClass
|
||||
object Local : EffectiveVisibility("local") {
|
||||
override fun relation(other: EffectiveVisibility, typeCheckerContextProvider: TypeCheckerProviderContext): Permissiveness =
|
||||
if (this == other || Private == other) Permissiveness.SAME else Permissiveness.LESS
|
||||
if (this == other || PrivateInClass == other) Permissiveness.SAME else Permissiveness.LESS
|
||||
|
||||
override fun toVisibility(): Visibility = Visibilities.Local
|
||||
}
|
||||
|
||||
// Private with File container
|
||||
object PrivateInFile : EffectiveVisibility("private-in-file", privateApi = true) {
|
||||
override fun relation(other: EffectiveVisibility, typeCheckerContextProvider: TypeCheckerProviderContext): Permissiveness =
|
||||
when (other) {
|
||||
this -> Permissiveness.SAME
|
||||
Private, Local -> Permissiveness.MORE
|
||||
PrivateInClass, Local -> Permissiveness.MORE
|
||||
else -> Permissiveness.LESS
|
||||
}
|
||||
|
||||
@@ -68,7 +69,7 @@ sealed class EffectiveVisibility(val name: String, val publicApi: Boolean = fals
|
||||
override fun relation(other: EffectiveVisibility, typeCheckerContextProvider: TypeCheckerProviderContext): Permissiveness =
|
||||
when (other) {
|
||||
Public -> Permissiveness.LESS
|
||||
Private, PrivateInFile, Local, InternalProtectedBound, is InternalProtected -> Permissiveness.MORE
|
||||
PrivateInClass, PrivateInFile, Local, InternalProtectedBound, is InternalProtected -> Permissiveness.MORE
|
||||
is InternalOrPackage -> Permissiveness.SAME
|
||||
ProtectedBound, is Protected -> Permissiveness.UNKNOWN
|
||||
}
|
||||
@@ -76,7 +77,7 @@ sealed class EffectiveVisibility(val name: String, val publicApi: Boolean = fals
|
||||
override fun lowerBound(other: EffectiveVisibility, typeCheckerContextProvider: TypeCheckerProviderContext): EffectiveVisibility =
|
||||
when (other) {
|
||||
Public -> this
|
||||
Private, PrivateInFile, Local, InternalProtectedBound, is InternalOrPackage, is InternalProtected -> other
|
||||
PrivateInClass, PrivateInFile, Local, InternalProtectedBound, is InternalOrPackage, is InternalProtected -> other
|
||||
is Protected -> InternalProtected(other.containerTypeConstructor)
|
||||
ProtectedBound -> InternalProtectedBound
|
||||
}
|
||||
@@ -101,7 +102,7 @@ sealed class EffectiveVisibility(val name: String, val publicApi: Boolean = fals
|
||||
override fun relation(other: EffectiveVisibility, typeCheckerContextProvider: TypeCheckerProviderContext): Permissiveness =
|
||||
when (other) {
|
||||
Public -> Permissiveness.LESS
|
||||
Private, PrivateInFile, Local, ProtectedBound, InternalProtectedBound -> Permissiveness.MORE
|
||||
PrivateInClass, PrivateInFile, Local, ProtectedBound, InternalProtectedBound -> Permissiveness.MORE
|
||||
is Protected -> containerRelation(containerTypeConstructor, other.containerTypeConstructor, typeCheckerContextProvider)
|
||||
is InternalProtected -> when (containerRelation(
|
||||
containerTypeConstructor,
|
||||
@@ -118,7 +119,7 @@ sealed class EffectiveVisibility(val name: String, val publicApi: Boolean = fals
|
||||
override fun lowerBound(other: EffectiveVisibility, typeCheckerContextProvider: TypeCheckerProviderContext): EffectiveVisibility =
|
||||
when (other) {
|
||||
Public -> this
|
||||
Private, PrivateInFile, Local, ProtectedBound, InternalProtectedBound -> other
|
||||
PrivateInClass, PrivateInFile, Local, ProtectedBound, InternalProtectedBound -> other
|
||||
is Protected -> when (relation(other, typeCheckerContextProvider)) {
|
||||
Permissiveness.SAME, Permissiveness.MORE -> this
|
||||
Permissiveness.LESS -> other
|
||||
@@ -139,7 +140,7 @@ sealed class EffectiveVisibility(val name: String, val publicApi: Boolean = fals
|
||||
override fun relation(other: EffectiveVisibility, typeCheckerContextProvider: TypeCheckerProviderContext): Permissiveness =
|
||||
when (other) {
|
||||
Public, is Protected -> Permissiveness.LESS
|
||||
Private, PrivateInFile, Local, InternalProtectedBound -> Permissiveness.MORE
|
||||
PrivateInClass, PrivateInFile, Local, InternalProtectedBound -> Permissiveness.MORE
|
||||
ProtectedBound -> Permissiveness.SAME
|
||||
is InternalOrPackage, is InternalProtected -> Permissiveness.UNKNOWN
|
||||
}
|
||||
@@ -147,7 +148,7 @@ sealed class EffectiveVisibility(val name: String, val publicApi: Boolean = fals
|
||||
override fun lowerBound(other: EffectiveVisibility, typeCheckerContextProvider: TypeCheckerProviderContext): EffectiveVisibility =
|
||||
when (other) {
|
||||
Public, is Protected -> this
|
||||
Private, PrivateInFile, Local, ProtectedBound, InternalProtectedBound -> other
|
||||
PrivateInClass, PrivateInFile, Local, ProtectedBound, InternalProtectedBound -> other
|
||||
is InternalOrPackage, is InternalProtected -> InternalProtectedBound
|
||||
}
|
||||
|
||||
@@ -168,7 +169,7 @@ sealed class EffectiveVisibility(val name: String, val publicApi: Boolean = fals
|
||||
override fun relation(other: EffectiveVisibility, typeCheckerContextProvider: TypeCheckerProviderContext): Permissiveness =
|
||||
when (other) {
|
||||
Public, is InternalOrPackage -> Permissiveness.LESS
|
||||
Private, PrivateInFile, Local, InternalProtectedBound -> Permissiveness.MORE
|
||||
PrivateInClass, PrivateInFile, Local, InternalProtectedBound -> Permissiveness.MORE
|
||||
is InternalProtected -> containerRelation(
|
||||
containerTypeConstructor,
|
||||
other.containerTypeConstructor,
|
||||
@@ -189,7 +190,7 @@ sealed class EffectiveVisibility(val name: String, val publicApi: Boolean = fals
|
||||
override fun lowerBound(other: EffectiveVisibility, typeCheckerContextProvider: TypeCheckerProviderContext): EffectiveVisibility =
|
||||
when (other) {
|
||||
Public, is InternalOrPackage -> this
|
||||
Private, PrivateInFile, Local, InternalProtectedBound -> other
|
||||
PrivateInClass, PrivateInFile, Local, InternalProtectedBound -> other
|
||||
is Protected, is InternalProtected -> when (relation(other, typeCheckerContextProvider)) {
|
||||
Permissiveness.SAME, Permissiveness.MORE -> this
|
||||
Permissiveness.LESS -> other
|
||||
@@ -206,7 +207,7 @@ sealed class EffectiveVisibility(val name: String, val publicApi: Boolean = fals
|
||||
override fun relation(other: EffectiveVisibility, typeCheckerContextProvider: TypeCheckerProviderContext): Permissiveness =
|
||||
when (other) {
|
||||
Public, is Protected, is InternalProtected, ProtectedBound, is InternalOrPackage -> Permissiveness.LESS
|
||||
Private, PrivateInFile, Local -> Permissiveness.MORE
|
||||
PrivateInClass, PrivateInFile, Local -> Permissiveness.MORE
|
||||
InternalProtectedBound -> Permissiveness.SAME
|
||||
}
|
||||
|
||||
@@ -228,7 +229,7 @@ sealed class EffectiveVisibility(val name: String, val publicApi: Boolean = fals
|
||||
when (relation(other, typeCheckerContextProvider)) {
|
||||
Permissiveness.SAME, Permissiveness.LESS -> this
|
||||
Permissiveness.MORE -> other
|
||||
Permissiveness.UNKNOWN -> Private
|
||||
Permissiveness.UNKNOWN -> PrivateInClass
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -20,10 +20,10 @@ fun DescriptorVisibility.effectiveVisibility(
|
||||
|
||||
private fun DescriptorVisibility.forVisibility(descriptor: DeclarationDescriptor, checkPublishedApi: Boolean = false): EffectiveVisibility =
|
||||
when (this) {
|
||||
DescriptorVisibilities.PRIVATE_TO_THIS, DescriptorVisibilities.INVISIBLE_FAKE -> EffectiveVisibility.Private
|
||||
DescriptorVisibilities.PRIVATE_TO_THIS, DescriptorVisibilities.INVISIBLE_FAKE -> EffectiveVisibility.PrivateInClass
|
||||
DescriptorVisibilities.PRIVATE -> if (descriptor is ClassDescriptor &&
|
||||
descriptor.containingDeclaration is PackageFragmentDescriptor
|
||||
) EffectiveVisibility.PrivateInFile else EffectiveVisibility.Private
|
||||
) EffectiveVisibility.PrivateInFile else EffectiveVisibility.PrivateInClass
|
||||
DescriptorVisibilities.PROTECTED -> EffectiveVisibility.Protected(
|
||||
(descriptor.containingDeclaration as? ClassDescriptor)?.defaultType?.constructor
|
||||
)
|
||||
|
||||
Reference in New Issue
Block a user