Minor: simplify isVisible of Visibilities.INTERNAL and write comment on non-obvious line

This commit is contained in:
Zalim Bashorov
2017-04-10 20:17:23 +03:00
parent 712b2c8117
commit 5f0e896843
@@ -206,8 +206,14 @@ public class Visibilities {
@Override
public boolean isVisible(@Nullable ReceiverValue receiver, @NotNull DeclarationDescriptorWithVisibility what, @NotNull DeclarationDescriptor from) {
DeclarationDescriptor fromOrModule = from instanceof PackageViewDescriptor ? ((PackageViewDescriptor) from).getModule() : from;
if (!DescriptorUtils.getContainingModule(fromOrModule).shouldSeeInternalsOf(DescriptorUtils.getContainingModule(what))) return false;
ModuleDescriptor whatModule = DescriptorUtils.getContainingModule(what);
ModuleDescriptor fromModule = DescriptorUtils.getContainingModule(from);
// Can't invert this condition because CLI compiler analyzes sources as like all in the one module
// and for modules with circular dependency (chunk) JPS provides sources of all modules,
// so we can't be sure that references to an internal member are correct.
if (!fromModule.shouldSeeInternalsOf(whatModule)) return false;
return MODULE_VISIBILITY_HELPER.isInFriendModule(what, from);
}