Get rid of Visibility.effectiveVisibility member
This commit is contained in:
@@ -63,9 +63,9 @@ public class JavaVisibilities {
|
|||||||
return Visibilities.PROTECTED;
|
return Visibilities.PROTECTED;
|
||||||
}
|
}
|
||||||
|
|
||||||
@NotNull
|
@Nullable
|
||||||
@Override
|
@Override
|
||||||
public EffectiveVisibility effectiveVisibility(@NotNull DeclarationDescriptor classDescriptor, boolean checkPublishedApi) {
|
public EffectiveVisibility customEffectiveVisibility() {
|
||||||
return EffectiveVisibility.PackagePrivate.INSTANCE;
|
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.KotlinType
|
||||||
import org.jetbrains.kotlin.types.checker.ClassicTypeCheckerContext
|
import org.jetbrains.kotlin.types.checker.ClassicTypeCheckerContext
|
||||||
|
|
||||||
fun effectiveVisibility(visibility: Visibility, descriptor: DeclarationDescriptor, checkPublishedApi: Boolean = false) =
|
fun Visibility.effectiveVisibility(
|
||||||
visibility.forVisibility(descriptor, checkPublishedApi)
|
descriptor: DeclarationDescriptor,
|
||||||
|
checkPublishedApi: Boolean = false
|
||||||
|
): EffectiveVisibility {
|
||||||
|
return customEffectiveVisibility() ?: normalize().forVisibility(descriptor, checkPublishedApi)
|
||||||
|
}
|
||||||
|
|
||||||
private fun Visibility.forVisibility(descriptor: DeclarationDescriptor, checkPublishedApi: Boolean = false): EffectiveVisibility =
|
private fun Visibility.forVisibility(descriptor: DeclarationDescriptor, checkPublishedApi: Boolean = false): EffectiveVisibility =
|
||||||
when (this) {
|
when (this) {
|
||||||
|
|||||||
@@ -19,8 +19,8 @@ package org.jetbrains.kotlin.descriptors
|
|||||||
import org.jetbrains.kotlin.resolve.scopes.receivers.ReceiverValue
|
import org.jetbrains.kotlin.resolve.scopes.receivers.ReceiverValue
|
||||||
|
|
||||||
abstract class Visibility protected constructor(
|
abstract class Visibility protected constructor(
|
||||||
val name: String,
|
val name: String,
|
||||||
val isPublicAPI: Boolean
|
val isPublicAPI: Boolean
|
||||||
) {
|
) {
|
||||||
/**
|
/**
|
||||||
* @param receiver can be used to determine callee accessibility for some special receiver value
|
* @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
|
open val externalDisplayName: String
|
||||||
get() = internalDisplayName
|
get() = internalDisplayName
|
||||||
|
|
||||||
override final fun toString() = internalDisplayName
|
final override fun toString() = internalDisplayName
|
||||||
|
|
||||||
open fun normalize(): Visibility = this
|
open fun normalize(): Visibility = this
|
||||||
|
|
||||||
// Should be overloaded in Java visibilities
|
// 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 psiFile = (descriptor.source.containingFile as? PsiSourceFile)?.psiFile ?: return
|
||||||
val file = VfsUtilCore.virtualToIoFile(psiFile.virtualFile)
|
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) {
|
val fqName = when (descriptor) {
|
||||||
is PropertyGetterDescriptor -> {
|
is PropertyGetterDescriptor -> {
|
||||||
|
|||||||
@@ -447,7 +447,8 @@ public final class TranslationUtils {
|
|||||||
}
|
}
|
||||||
|
|
||||||
DeclarationDescriptor container = descriptor.getContainingDeclaration();
|
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) {
|
if (KotlinBuiltIns.isCharOrNullableChar(returnType) && container instanceof ClassDescriptor && isPublic) {
|
||||||
ClassDescriptor containingClass = (ClassDescriptor) container;
|
ClassDescriptor containingClass = (ClassDescriptor) container;
|
||||||
FqNameUnsafe containingClassName = DescriptorUtilsKt.getFqNameUnsafe(containingClass);
|
FqNameUnsafe containingClassName = DescriptorUtilsKt.getFqNameUnsafe(containingClass);
|
||||||
|
|||||||
Reference in New Issue
Block a user