Introduce UNKNOWN visibility as default in FunctionDescriptor
It's needed to prevent NPE when requesting non-nullable visibility of descriptor before `initialize` has been called. Currently it happens because of indirect calls of `DescriptorUtils.isLocal` between descriptor creation and it's initialization.
This commit is contained in:
@@ -173,6 +173,22 @@ public class Visibilities {
|
||||
}
|
||||
};
|
||||
|
||||
// Currently used as default visibility of FunctionDescriptor
|
||||
// It's needed to prevent NPE when requesting non-nullable visibility of descriptor before `initialize` has been called
|
||||
public static final Visibility UNKNOWN = new Visibility("unknown", false) {
|
||||
@Override
|
||||
public boolean mustCheckInImports() {
|
||||
throw new IllegalStateException("This method shouldn't be invoked for UNKNOWN visibility");
|
||||
}
|
||||
|
||||
@Override
|
||||
protected boolean isVisible(
|
||||
@NotNull ReceiverValue receiver, @NotNull DeclarationDescriptorWithVisibility what, @NotNull DeclarationDescriptor from
|
||||
) {
|
||||
return false;
|
||||
}
|
||||
};
|
||||
|
||||
public static final Set<Visibility> INVISIBLE_FROM_OTHER_MODULES =
|
||||
Collections.unmodifiableSet(KotlinPackage.setOf(PRIVATE, PRIVATE_TO_THIS, INTERNAL, LOCAL));
|
||||
|
||||
|
||||
+1
-1
@@ -40,7 +40,7 @@ public abstract class FunctionDescriptorImpl extends DeclarationDescriptorNonRoo
|
||||
private ReceiverParameterDescriptor extensionReceiverParameter;
|
||||
private ReceiverParameterDescriptor dispatchReceiverParameter;
|
||||
private Modality modality;
|
||||
private Visibility visibility;
|
||||
private Visibility visibility = Visibilities.UNKNOWN;
|
||||
private final Set<FunctionDescriptor> overriddenFunctions = new LinkedHashSet<FunctionDescriptor>(); // LinkedHashSet is essential here
|
||||
private final FunctionDescriptor original;
|
||||
private final Kind kind;
|
||||
|
||||
Reference in New Issue
Block a user