Rename EffectiveVisibility.Private to PrivateInClass

This commit is contained in:
Mikhail Glukhikh
2021-04-07 14:27:32 +03:00
parent 3c9f0e4775
commit 6ee169c01e
8 changed files with 25 additions and 24 deletions
@@ -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
}
}