Search in sources :

Example 1 with IrBuiltinsPackageFragmentDescriptor

use of org.jetbrains.kotlin.ir.descriptors.IrBuiltinsPackageFragmentDescriptor in project kotlin by JetBrains.

the class KotlinTypeMapper method internalNameForPackageMemberOwner.

@NotNull
private String internalNameForPackageMemberOwner(@NotNull CallableMemberDescriptor descriptor, boolean publicFacade) {
    boolean isAccessor = descriptor instanceof AccessorForCallableDescriptor;
    if (isAccessor) {
        descriptor = ((AccessorForCallableDescriptor) descriptor).getCalleeDescriptor();
    }
    KtFile file = DescriptorToSourceUtils.getContainingFile(descriptor);
    if (file != null) {
        Visibility visibility = descriptor.getVisibility();
        if (!publicFacade || isNonConstProperty(descriptor) || Visibilities.isPrivate(visibility) || isAccessor) /*Cause of KT-9603*/
        {
            return FileClasses.getFileClassInternalName(fileClassesProvider, file);
        } else {
            return FileClasses.getFacadeClassInternalName(fileClassesProvider, file);
        }
    }
    CallableMemberDescriptor directMember = DescriptorUtils.getDirectMember(descriptor);
    if (directMember instanceof DeserializedCallableMemberDescriptor) {
        String facadeFqName = getPackageMemberOwnerInternalName((DeserializedCallableMemberDescriptor) directMember, publicFacade);
        if (facadeFqName != null)
            return facadeFqName;
    }
    if (descriptor.getContainingDeclaration() instanceof IrBuiltinsPackageFragmentDescriptor) {
        return descriptor.getContainingDeclaration().getName().asString();
    }
    throw new RuntimeException("Could not find package member for " + descriptor + " in package fragment " + descriptor.getContainingDeclaration());
}
Also used : DeserializedCallableMemberDescriptor(org.jetbrains.kotlin.serialization.deserialization.descriptors.DeserializedCallableMemberDescriptor) KtFile(org.jetbrains.kotlin.psi.KtFile) IrBuiltinsPackageFragmentDescriptor(org.jetbrains.kotlin.ir.descriptors.IrBuiltinsPackageFragmentDescriptor) JavaCallableMemberDescriptor(org.jetbrains.kotlin.load.java.descriptors.JavaCallableMemberDescriptor) DeserializedCallableMemberDescriptor(org.jetbrains.kotlin.serialization.deserialization.descriptors.DeserializedCallableMemberDescriptor) NotNull(org.jetbrains.annotations.NotNull)

Aggregations

NotNull (org.jetbrains.annotations.NotNull)1 IrBuiltinsPackageFragmentDescriptor (org.jetbrains.kotlin.ir.descriptors.IrBuiltinsPackageFragmentDescriptor)1 JavaCallableMemberDescriptor (org.jetbrains.kotlin.load.java.descriptors.JavaCallableMemberDescriptor)1 KtFile (org.jetbrains.kotlin.psi.KtFile)1 DeserializedCallableMemberDescriptor (org.jetbrains.kotlin.serialization.deserialization.descriptors.DeserializedCallableMemberDescriptor)1