Clearify diagnostic messages that involve internal visibilities
KT-7354 Fixed Visibility.displayText is deprecated with warning. Diagnostics for java visibilities changed.
This commit is contained in:
@@ -47,10 +47,16 @@ public class JavaVisibilities {
|
||||
|
||||
@NotNull
|
||||
@Override
|
||||
public String getDisplayName() {
|
||||
public String getInternalDisplayName() {
|
||||
return "public/*package*/";
|
||||
}
|
||||
|
||||
@NotNull
|
||||
@Override
|
||||
public String getExternalDisplayName() {
|
||||
return "package-private";
|
||||
}
|
||||
|
||||
@NotNull
|
||||
@Override
|
||||
public Visibility normalize() {
|
||||
@@ -78,10 +84,16 @@ public class JavaVisibilities {
|
||||
|
||||
@NotNull
|
||||
@Override
|
||||
public String getDisplayName() {
|
||||
public String getInternalDisplayName() {
|
||||
return "protected/*protected static*/";
|
||||
}
|
||||
|
||||
@NotNull
|
||||
@Override
|
||||
public String getExternalDisplayName() {
|
||||
return "protected";
|
||||
}
|
||||
|
||||
@NotNull
|
||||
@Override
|
||||
public Visibility normalize() {
|
||||
@@ -111,10 +123,16 @@ public class JavaVisibilities {
|
||||
|
||||
@NotNull
|
||||
@Override
|
||||
public String getDisplayName() {
|
||||
public String getInternalDisplayName() {
|
||||
return "protected/*protected and package*/";
|
||||
}
|
||||
|
||||
@NotNull
|
||||
@Override
|
||||
public String getExternalDisplayName() {
|
||||
return "protected";
|
||||
}
|
||||
|
||||
@NotNull
|
||||
@Override
|
||||
public Visibility normalize() {
|
||||
|
||||
@@ -126,7 +126,7 @@ public class Visibilities {
|
||||
|
||||
@NotNull
|
||||
@Override
|
||||
public String getDisplayName() {
|
||||
public String getInternalDisplayName() {
|
||||
return "private/*private to this*/";
|
||||
}
|
||||
};
|
||||
@@ -270,6 +270,12 @@ public class Visibilities {
|
||||
public boolean isVisible(@Nullable ReceiverValue receiver, @NotNull DeclarationDescriptorWithVisibility what, @NotNull DeclarationDescriptor from) {
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
@NotNull
|
||||
public String getExternalDisplayName() {
|
||||
return "invisible (private in a supertype)";
|
||||
}
|
||||
};
|
||||
|
||||
// Currently used as default visibility of FunctionDescriptor
|
||||
|
||||
@@ -56,10 +56,23 @@ abstract class Visibility protected constructor(
|
||||
return Visibilities.compareLocal(this, visibility)
|
||||
}
|
||||
|
||||
open val displayName: String
|
||||
// internal representation for descriptors
|
||||
open val internalDisplayName: String
|
||||
get() = name
|
||||
|
||||
override final fun toString() = displayName
|
||||
// external representation for diagnostics
|
||||
open val externalDisplayName: String
|
||||
get() = internalDisplayName
|
||||
|
||||
@Deprecated(
|
||||
"Visibility.displayName is deprecated, use internalDisplayName instead",
|
||||
ReplaceWith("internalDisplayName"),
|
||||
level = DeprecationLevel.WARNING
|
||||
)
|
||||
open val displayName: String
|
||||
get() = internalDisplayName
|
||||
|
||||
override final fun toString() = internalDisplayName
|
||||
|
||||
open fun normalize(): Visibility = this
|
||||
|
||||
|
||||
@@ -481,7 +481,7 @@ internal class DescriptorRendererImpl(
|
||||
visibility = visibility.normalize()
|
||||
}
|
||||
if (!renderDefaultVisibility && visibility == Visibilities.DEFAULT_VISIBILITY) return false
|
||||
builder.append(renderKeyword(visibility.displayName)).append(" ")
|
||||
builder.append(renderKeyword(visibility.internalDisplayName)).append(" ")
|
||||
return true
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user