use of org.jetbrains.kotlin.serialization.deserialization.descriptors.DeserializedClassDescriptor in project kotlin by JetBrains.
the class AbstractLoadJavaTest method doTestCompiledKotlin.
private void doTestCompiledKotlin(@NotNull String ktFileName, @NotNull ConfigurationKind configurationKind, boolean useTypeTableInSerializer) throws Exception {
File ktFile = new File(ktFileName);
File txtFile = new File(ktFileName.replaceFirst("\\.kt$", ".txt"));
CompilerConfiguration configuration = newConfiguration(configurationKind, TestJdkKind.MOCK_JDK, getAnnotationsJar());
if (useTypeTableInSerializer) {
configuration.put(JVMConfigurationKeys.USE_TYPE_TABLE, true);
}
KotlinCoreEnvironment environment = KotlinCoreEnvironment.createForTests(getTestRootDisposable(), configuration, EnvironmentConfigFiles.JVM_CONFIG_FILES);
ModuleDescriptor module = compileKotlinToDirAndGetModule(Collections.singletonList(ktFile), tmpdir, environment);
PackageViewDescriptor packageFromSource = module.getPackage(TEST_PACKAGE_FQNAME);
Assert.assertEquals("test", packageFromSource.getName().asString());
PackageViewDescriptor packageFromBinary = LoadDescriptorUtil.loadTestPackageAndBindingContextFromJavaRoot(tmpdir, getTestRootDisposable(), getJdkKind(), configurationKind, true).first;
for (DeclarationDescriptor descriptor : DescriptorUtils.getAllDescriptors(packageFromBinary.getMemberScope())) {
if (descriptor instanceof ClassDescriptor) {
assert descriptor instanceof DeserializedClassDescriptor : DescriptorUtils.getFqName(descriptor) + " is loaded as " + descriptor.getClass();
}
}
DescriptorValidator.validate(errorTypesForbidden(), packageFromSource);
DescriptorValidator.validate(new DeserializedScopeValidationVisitor(), packageFromBinary);
Configuration comparatorConfiguration = COMPARATOR_CONFIGURATION.checkPrimaryConstructors(true).checkPropertyAccessors(true);
compareDescriptors(packageFromSource, packageFromBinary, comparatorConfiguration, txtFile);
}
use of org.jetbrains.kotlin.serialization.deserialization.descriptors.DeserializedClassDescriptor 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);
}
}
}
Aggregations