Search in sources :

Example 1 with LazyJavaPackageFragment

use of org.jetbrains.kotlin.load.java.lazy.descriptors.LazyJavaPackageFragment in project kotlin by JetBrains.

the class KotlinTypeMapper method checkOwnerCompatibility.

private void checkOwnerCompatibility(@NotNull FunctionDescriptor descriptor) {
    if (!(descriptor instanceof DeserializedCallableMemberDescriptor))
        return;
    KotlinJvmBinaryClass ownerClass = null;
    DeclarationDescriptor container = descriptor.getContainingDeclaration();
    if (container instanceof DeserializedClassDescriptor) {
        SourceElement source = ((DeserializedClassDescriptor) container).getSource();
        if (source instanceof KotlinJvmBinarySourceElement) {
            ownerClass = ((KotlinJvmBinarySourceElement) source).getBinaryClass();
        }
    } else if (container instanceof LazyJavaPackageFragment) {
        SourceElement source = ((LazyJavaPackageFragment) container).getSource();
        if (source instanceof KotlinJvmBinaryPackageSourceElement) {
            ownerClass = ((KotlinJvmBinaryPackageSourceElement) source).getRepresentativeBinaryClass();
        }
    }
    if (ownerClass != null) {
        JvmBytecodeBinaryVersion version = ownerClass.getClassHeader().getBytecodeVersion();
        if (!version.isCompatible()) {
            incompatibleClassTracker.record(ownerClass);
        }
    }
}
Also used : DeserializedCallableMemberDescriptor(org.jetbrains.kotlin.serialization.deserialization.descriptors.DeserializedCallableMemberDescriptor) LazyJavaPackageFragment(org.jetbrains.kotlin.load.java.lazy.descriptors.LazyJavaPackageFragment) JvmBytecodeBinaryVersion(org.jetbrains.kotlin.load.java.JvmBytecodeBinaryVersion) DeserializedClassDescriptor(org.jetbrains.kotlin.serialization.deserialization.descriptors.DeserializedClassDescriptor)

Example 2 with LazyJavaPackageFragment

use of org.jetbrains.kotlin.load.java.lazy.descriptors.LazyJavaPackageFragment in project kotlin by JetBrains.

the class KotlinTypeMapper method getPackageMemberContainingClassesInfo.

@Nullable
private static ContainingClassesInfo getPackageMemberContainingClassesInfo(@NotNull DeserializedCallableMemberDescriptor descriptor) {
    DeclarationDescriptor containingDeclaration = descriptor.getContainingDeclaration();
    if (containingDeclaration instanceof BuiltInsPackageFragment) {
        return new ContainingClassesInfo(FAKE_CLASS_ID_FOR_BUILTINS, FAKE_CLASS_ID_FOR_BUILTINS);
    }
    Name implClassName = JvmFileClassUtil.getImplClassName(descriptor);
    assert implClassName != null : "No implClassName for " + descriptor;
    String implSimpleName = implClassName.asString();
    String facadeSimpleName;
    if (containingDeclaration instanceof LazyJavaPackageFragment) {
        facadeSimpleName = ((LazyJavaPackageFragment) containingDeclaration).getFacadeSimpleNameForPartSimpleName(implSimpleName);
        if (facadeSimpleName == null)
            return null;
    } else if (containingDeclaration instanceof IncrementalMultifileClassPackageFragment) {
        facadeSimpleName = ((IncrementalMultifileClassPackageFragment) containingDeclaration).getMultifileClassName().asString();
    } else {
        throw new AssertionError("Unexpected package fragment for " + descriptor + ": " + containingDeclaration + " (" + containingDeclaration.getClass().getSimpleName() + ")");
    }
    return ContainingClassesInfo.forPackageMember(((PackageFragmentDescriptor) containingDeclaration).getFqName(), facadeSimpleName, implSimpleName);
}
Also used : IncrementalMultifileClassPackageFragment(org.jetbrains.kotlin.load.kotlin.incremental.IncrementalPackageFragmentProvider.IncrementalMultifileClassPackageFragment) BuiltInsPackageFragment(org.jetbrains.kotlin.builtins.BuiltInsPackageFragment) LazyJavaPackageFragment(org.jetbrains.kotlin.load.java.lazy.descriptors.LazyJavaPackageFragment) JvmClassName(org.jetbrains.kotlin.resolve.jvm.JvmClassName) Nullable(org.jetbrains.annotations.Nullable)

Aggregations

LazyJavaPackageFragment (org.jetbrains.kotlin.load.java.lazy.descriptors.LazyJavaPackageFragment)2 Nullable (org.jetbrains.annotations.Nullable)1 BuiltInsPackageFragment (org.jetbrains.kotlin.builtins.BuiltInsPackageFragment)1 JvmBytecodeBinaryVersion (org.jetbrains.kotlin.load.java.JvmBytecodeBinaryVersion)1 IncrementalMultifileClassPackageFragment (org.jetbrains.kotlin.load.kotlin.incremental.IncrementalPackageFragmentProvider.IncrementalMultifileClassPackageFragment)1 JvmClassName (org.jetbrains.kotlin.resolve.jvm.JvmClassName)1 DeserializedCallableMemberDescriptor (org.jetbrains.kotlin.serialization.deserialization.descriptors.DeserializedCallableMemberDescriptor)1 DeserializedClassDescriptor (org.jetbrains.kotlin.serialization.deserialization.descriptors.DeserializedClassDescriptor)1