Get rid of Visibility.effectiveVisibility member
This commit is contained in:
@@ -63,9 +63,9 @@ public class JavaVisibilities {
|
||||
return Visibilities.PROTECTED;
|
||||
}
|
||||
|
||||
@NotNull
|
||||
@Nullable
|
||||
@Override
|
||||
public EffectiveVisibility effectiveVisibility(@NotNull DeclarationDescriptor classDescriptor, boolean checkPublishedApi) {
|
||||
public EffectiveVisibility customEffectiveVisibility() {
|
||||
return EffectiveVisibility.PackagePrivate.INSTANCE;
|
||||
}
|
||||
};
|
||||
|
||||
@@ -9,8 +9,12 @@ import org.jetbrains.kotlin.resolve.descriptorUtil.isPublishedApi
|
||||
import org.jetbrains.kotlin.types.KotlinType
|
||||
import org.jetbrains.kotlin.types.checker.ClassicTypeCheckerContext
|
||||
|
||||
fun effectiveVisibility(visibility: Visibility, descriptor: DeclarationDescriptor, checkPublishedApi: Boolean = false) =
|
||||
visibility.forVisibility(descriptor, checkPublishedApi)
|
||||
fun Visibility.effectiveVisibility(
|
||||
descriptor: DeclarationDescriptor,
|
||||
checkPublishedApi: Boolean = false
|
||||
): EffectiveVisibility {
|
||||
return customEffectiveVisibility() ?: normalize().forVisibility(descriptor, checkPublishedApi)
|
||||
}
|
||||
|
||||
private fun Visibility.forVisibility(descriptor: DeclarationDescriptor, checkPublishedApi: Boolean = false): EffectiveVisibility =
|
||||
when (this) {
|
||||
|
||||
@@ -19,8 +19,8 @@ package org.jetbrains.kotlin.descriptors
|
||||
import org.jetbrains.kotlin.resolve.scopes.receivers.ReceiverValue
|
||||
|
||||
abstract class Visibility protected constructor(
|
||||
val name: String,
|
||||
val isPublicAPI: Boolean
|
||||
val name: String,
|
||||
val isPublicAPI: Boolean
|
||||
) {
|
||||
/**
|
||||
* @param receiver can be used to determine callee accessibility for some special receiver value
|
||||
@@ -64,10 +64,10 @@ abstract class Visibility protected constructor(
|
||||
open val externalDisplayName: String
|
||||
get() = internalDisplayName
|
||||
|
||||
override final fun toString() = internalDisplayName
|
||||
final override fun toString() = internalDisplayName
|
||||
|
||||
open fun normalize(): Visibility = this
|
||||
|
||||
// Should be overloaded in Java visibilities
|
||||
open fun effectiveVisibility(descriptor: DeclarationDescriptor, checkPublishedApi: Boolean) = effectiveVisibility(normalize(), descriptor, checkPublishedApi)
|
||||
open fun customEffectiveVisibility(): EffectiveVisibility? = null
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user