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
|
||||
}
|
||||
|
||||
+1
-1
@@ -133,7 +133,7 @@ private fun IncrementalResultsConsumer.reportInlineFunction(
|
||||
val psiFile = (descriptor.source.containingFile as? PsiSourceFile)?.psiFile ?: return
|
||||
val file = VfsUtilCore.virtualToIoFile(psiFile.virtualFile)
|
||||
|
||||
if (effectiveVisibility(descriptor.visibility, descriptor, true).privateApi) return
|
||||
if (descriptor.visibility.effectiveVisibility(descriptor, true).privateApi) return
|
||||
|
||||
val fqName = when (descriptor) {
|
||||
is PropertyGetterDescriptor -> {
|
||||
|
||||
@@ -447,7 +447,8 @@ public final class TranslationUtils {
|
||||
}
|
||||
|
||||
DeclarationDescriptor container = descriptor.getContainingDeclaration();
|
||||
boolean isPublic = descriptor.getVisibility().effectiveVisibility(descriptor, true).getPublicApi() && !forcePrivate;
|
||||
EffectiveVisibility effectiveVisibility = EffectiveVisibilityUtilsKt.effectiveVisibility(descriptor.getVisibility(), descriptor, true);
|
||||
boolean isPublic = effectiveVisibility.getPublicApi() && !forcePrivate;
|
||||
if (KotlinBuiltIns.isCharOrNullableChar(returnType) && container instanceof ClassDescriptor && isPublic) {
|
||||
ClassDescriptor containingClass = (ClassDescriptor) container;
|
||||
FqNameUnsafe containingClassName = DescriptorUtilsKt.getFqNameUnsafe(containingClass);
|
||||
|
||||
Reference in New Issue
Block a user