Remove kotlin.jvm.internal.KotlinPackage and corresponding code
This commit is contained in:
+5
-30
@@ -17,19 +17,19 @@
|
||||
package org.jetbrains.kotlin.codegen.serialization;
|
||||
|
||||
import com.intellij.openapi.util.Pair;
|
||||
import kotlin.jvm.functions.Function3;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
import org.jetbrains.kotlin.descriptors.CallableMemberDescriptor;
|
||||
import org.jetbrains.kotlin.descriptors.FunctionDescriptor;
|
||||
import org.jetbrains.kotlin.descriptors.PropertyDescriptor;
|
||||
import org.jetbrains.kotlin.descriptors.ValueParameterDescriptor;
|
||||
import org.jetbrains.kotlin.util.slicedMap.*;
|
||||
import org.jetbrains.kotlin.util.slicedMap.BasicWritableSlice;
|
||||
import org.jetbrains.kotlin.util.slicedMap.MutableSlicedMap;
|
||||
import org.jetbrains.kotlin.util.slicedMap.SlicedMapImpl;
|
||||
import org.jetbrains.kotlin.util.slicedMap.Slices;
|
||||
import org.jetbrains.org.objectweb.asm.Type;
|
||||
import org.jetbrains.org.objectweb.asm.commons.Method;
|
||||
|
||||
import java.util.Collection;
|
||||
|
||||
public final class JvmSerializationBindings {
|
||||
public static final SerializationMappingSlice<FunctionDescriptor, Method> METHOD_FOR_FUNCTION =
|
||||
SerializationMappingSlice.create();
|
||||
@@ -70,32 +70,7 @@ public final class JvmSerializationBindings {
|
||||
BasicWritableSlice.initSliceDebugNames(JvmSerializationBindings.class);
|
||||
}
|
||||
|
||||
private final MutableSlicedMap map;
|
||||
|
||||
private JvmSerializationBindings(@NotNull MutableSlicedMap map) {
|
||||
this.map = map;
|
||||
}
|
||||
|
||||
public JvmSerializationBindings() {
|
||||
this(SlicedMapImpl.create());
|
||||
}
|
||||
|
||||
@NotNull
|
||||
public static JvmSerializationBindings union(@NotNull Collection<JvmSerializationBindings> bindings) {
|
||||
final MutableSlicedMap result = SlicedMapImpl.create();
|
||||
|
||||
for (JvmSerializationBindings binding : bindings) {
|
||||
binding.map.forEach(new Function3<WritableSlice, Object, Object, Void>() {
|
||||
@Override
|
||||
public Void invoke(WritableSlice slice, Object key, Object value) {
|
||||
result.put(slice, key, value);
|
||||
return null;
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
return new JvmSerializationBindings(result);
|
||||
}
|
||||
private final MutableSlicedMap map = SlicedMapImpl.create();
|
||||
|
||||
public <K, V> void put(@NotNull SerializationMappingSlice<K, V> slice, @NotNull K key, @NotNull V value) {
|
||||
map.put(slice, key, value);
|
||||
|
||||
+4
-10
@@ -17,16 +17,12 @@
|
||||
package org.jetbrains.kotlin.resolve.jvm.diagnostics
|
||||
|
||||
import com.intellij.psi.PsiElement
|
||||
import org.jetbrains.kotlin.descriptors.DeclarationDescriptor
|
||||
import org.jetbrains.kotlin.descriptors.PackageFragmentDescriptor
|
||||
import org.jetbrains.kotlin.psi.KtFile
|
||||
import org.jetbrains.kotlin.descriptors.ClassDescriptor
|
||||
import org.jetbrains.kotlin.psi.KtClassOrObject
|
||||
import org.jetbrains.kotlin.descriptors.FunctionDescriptor
|
||||
import org.jetbrains.kotlin.resolve.jvm.diagnostics.JvmDeclarationOriginKind.*
|
||||
import org.jetbrains.kotlin.descriptors.CallableMemberDescriptor
|
||||
import org.jetbrains.kotlin.descriptors.*
|
||||
import org.jetbrains.kotlin.name.FqName
|
||||
import org.jetbrains.kotlin.psi.KtClassOrObject
|
||||
import org.jetbrains.kotlin.psi.KtFile
|
||||
import org.jetbrains.kotlin.resolve.DescriptorToSourceUtils
|
||||
import org.jetbrains.kotlin.resolve.jvm.diagnostics.JvmDeclarationOriginKind.*
|
||||
|
||||
public enum class MemberKind { FIELD, METHOD }
|
||||
|
||||
@@ -34,7 +30,6 @@ public data class RawSignature(public val name: String, public val desc: String,
|
||||
|
||||
public enum class JvmDeclarationOriginKind {
|
||||
OTHER,
|
||||
PACKAGE_FACADE,
|
||||
PACKAGE_PART,
|
||||
INTERFACE_DEFAULT_IMPL,
|
||||
DELEGATION_TO_DEFAULT_IMPLS,
|
||||
@@ -68,7 +63,6 @@ public fun OtherOrigin(descriptor: DeclarationDescriptor): JvmDeclarationOrigin
|
||||
public fun Bridge(descriptor: DeclarationDescriptor, element: PsiElement? = DescriptorToSourceUtils.descriptorToDeclaration(descriptor)): JvmDeclarationOrigin =
|
||||
JvmDeclarationOrigin(BRIDGE, element, descriptor)
|
||||
|
||||
public fun PackageFacade(descriptor: PackageFragmentDescriptor): JvmDeclarationOrigin = JvmDeclarationOrigin(PACKAGE_FACADE, null, descriptor)
|
||||
public fun PackagePart(file: KtFile, descriptor: PackageFragmentDescriptor): JvmDeclarationOrigin = JvmDeclarationOrigin(PACKAGE_PART, file, descriptor)
|
||||
|
||||
/**
|
||||
|
||||
@@ -17,18 +17,18 @@
|
||||
package org.jetbrains.kotlin.asJava
|
||||
|
||||
import com.intellij.psi.PsiElement
|
||||
import org.jetbrains.kotlin.resolve.diagnostics.Diagnostics
|
||||
import com.intellij.psi.search.GlobalSearchScope
|
||||
import org.jetbrains.kotlin.diagnostics.Diagnostic
|
||||
import org.jetbrains.kotlin.resolve.jvm.diagnostics.ErrorsJvm.*
|
||||
import org.jetbrains.kotlin.resolve.jvm.diagnostics.ConflictingJvmDeclarationsData
|
||||
import org.jetbrains.kotlin.resolve.jvm.diagnostics.JvmDeclarationOriginKind.*
|
||||
import org.jetbrains.kotlin.diagnostics.Errors.*
|
||||
import org.jetbrains.kotlin.diagnostics.DiagnosticFactory.*
|
||||
import org.jetbrains.kotlin.diagnostics.DiagnosticFactory
|
||||
import org.jetbrains.kotlin.diagnostics.DiagnosticFactory.cast
|
||||
import org.jetbrains.kotlin.diagnostics.Errors.*
|
||||
import org.jetbrains.kotlin.fileClasses.NoResolveFileClassesProvider
|
||||
import org.jetbrains.kotlin.psi.*
|
||||
import org.jetbrains.kotlin.resolve.diagnostics.Diagnostics
|
||||
import org.jetbrains.kotlin.resolve.jvm.diagnostics.ConflictingJvmDeclarationsData
|
||||
import org.jetbrains.kotlin.resolve.jvm.diagnostics.ErrorsJvm
|
||||
import org.jetbrains.kotlin.resolve.jvm.diagnostics.ErrorsJvm.*
|
||||
import org.jetbrains.kotlin.resolve.jvm.diagnostics.JvmDeclarationOriginKind.*
|
||||
|
||||
public fun getJvmSignatureDiagnostics(element: PsiElement, otherDiagnostics: Diagnostics, moduleScope: GlobalSearchScope): Diagnostics? {
|
||||
fun getDiagnosticsForFileFacade(file: KtFile): Diagnostics? {
|
||||
@@ -118,8 +118,8 @@ class FilteredJvmDiagnostics(val jvmDiagnostics: Diagnostics, val otherDiagnosti
|
||||
// in case of implementation copied from a super trait there will be both diagnostics on the same signature
|
||||
other.factory == ErrorsJvm.CONFLICTING_JVM_DECLARATIONS && (me.factory == ACCIDENTAL_OVERRIDE ||
|
||||
me.factory == CONFLICTING_INHERITED_JVM_DECLARATIONS)
|
||||
// there are paris of corresponding signatures that frequently clash simultaneously: package facade & part, trait and trait-impl
|
||||
|| other.data() higherThan me.data()
|
||||
// there are paris of corresponding signatures that frequently clash simultaneously: multifile class & part, trait and trait-impl
|
||||
|| other.data().higherThan(me.data())
|
||||
)
|
||||
}
|
||||
}
|
||||
@@ -140,7 +140,6 @@ class FilteredJvmDiagnostics(val jvmDiagnostics: Diagnostics, val otherDiagnosti
|
||||
|
||||
private infix fun ConflictingJvmDeclarationsData.higherThan(other: ConflictingJvmDeclarationsData): Boolean {
|
||||
return when (other.classOrigin.originKind) {
|
||||
PACKAGE_PART -> this.classOrigin.originKind == PACKAGE_FACADE
|
||||
INTERFACE_DEFAULT_IMPL -> this.classOrigin.originKind != INTERFACE_DEFAULT_IMPL
|
||||
MULTIFILE_CLASS_PART -> this.classOrigin.originKind == MULTIFILE_CLASS
|
||||
else -> false
|
||||
|
||||
+1
-2
@@ -8,6 +8,5 @@ public fun kotlin.Throwable.printStackTrace(writer: java.io.PrintWriter): kotlin
|
||||
(note: this may be caused by the fact that some classes compiled with an incompatible version of Kotlin were found in the classpath. Such classes cannot be loaded properly by this version of Kotlin compiler. See below for more information)
|
||||
1.printStackTrace(2, 3)
|
||||
^
|
||||
compiler/testData/cli/jvm/wrongAbiVersionLib/bin/ClassWithWrongAbiVersion.class: error: class 'ClassWithWrongAbiVersion' was compiled with an incompatible version of Kotlin. Its ABI version is unknown, expected ABI version is $ABI_VERSION$
|
||||
compiler/testData/cli/jvm/wrongAbiVersionLib/bin/wrong/WrongPackage.class: error: class 'wrong/WrongPackage' was compiled with an incompatible version of Kotlin. Its ABI version is unknown, expected ABI version is $ABI_VERSION$
|
||||
compiler/testData/cli/jvm/wrongAbiVersionLib/bin/ClassWithWrongAbiVersion.class: error: class 'ClassWithWrongAbiVersion' was compiled with an incompatible version of Kotlin. Its ABI version is 0.30.0, expected ABI version is $ABI_VERSION$
|
||||
COMPILATION_ERROR
|
||||
BIN
Binary file not shown.
Binary file not shown.
BIN
Binary file not shown.
BIN
Binary file not shown.
Vendored
BIN
Binary file not shown.
Binary file not shown.
Binary file not shown.
+1
-1
@@ -1,6 +1,6 @@
|
||||
/*
|
||||
To regenerate this test:
|
||||
1. Change JvmAbi.VERSION to -1
|
||||
1. Change JvmAbi.VERSION to an incompatible one, e.g. 0.30.0
|
||||
2. Run 'ant dist'
|
||||
3. Compile files with the newly built compiler from dist/
|
||||
|
||||
|
||||
@@ -30,12 +30,11 @@ import org.jetbrains.org.objectweb.asm.tree.MethodNode
|
||||
import java.util.*
|
||||
import kotlin.properties.Delegates
|
||||
|
||||
public object InlineTestUtil {
|
||||
object InlineTestUtil {
|
||||
private val KOTLIN_MULTIFILE_CLASS_DESC =
|
||||
"L" + AsmUtil.internalNameByFqNameWithoutInnerClasses(JvmAnnotationNames.KOTLIN_MULTIFILE_CLASS) + ";"
|
||||
|
||||
private val KOTLIN_PACKAGE_DESC = "L" + AsmUtil.internalNameByFqNameWithoutInnerClasses(JvmAnnotationNames.KOTLIN_PACKAGE) + ";"
|
||||
private val KOTLIN_MULTIFILE_CLASS_DESC = "L" + AsmUtil.internalNameByFqNameWithoutInnerClasses(JvmAnnotationNames.KOTLIN_MULTIFILE_CLASS) + ";"
|
||||
|
||||
public fun checkNoCallsToInline(files: Iterable<OutputFile>, sourceFiles: List<KtFile>) {
|
||||
fun checkNoCallsToInline(files: Iterable<OutputFile>, sourceFiles: List<KtFile>) {
|
||||
val inlineInfo = obtainInlineInfo(files)
|
||||
val inlineMethods = inlineInfo.inlineMethods
|
||||
assert(!inlineMethods.isEmpty()) { "There are no inline methods" }
|
||||
@@ -94,7 +93,7 @@ public object InlineTestUtil {
|
||||
private var skipMethodsOfThisClass = false
|
||||
|
||||
override fun visitAnnotation(desc: String, visible: Boolean): AnnotationVisitor? {
|
||||
if (desc == KOTLIN_PACKAGE_DESC || desc == KOTLIN_MULTIFILE_CLASS_DESC) {
|
||||
if (desc == KOTLIN_MULTIFILE_CLASS_DESC) {
|
||||
skipMethodsOfThisClass = true
|
||||
}
|
||||
return null
|
||||
|
||||
+1
-4
@@ -157,10 +157,7 @@ public abstract class AbstractJvmRuntimeDescriptorLoaderTest : TestCaseWithTmpdi
|
||||
val klass = classLoader.loadClass(className).sure { "Couldn't load class $className" }
|
||||
val header = ReflectKotlinClass.create(klass)?.getClassHeader()
|
||||
|
||||
if (header?.kind == KotlinClassHeader.Kind.PACKAGE_FACADE ||
|
||||
header?.kind == KotlinClassHeader.Kind.FILE_FACADE ||
|
||||
header?.kind == KotlinClassHeader.Kind.MULTIFILE_CLASS
|
||||
) {
|
||||
if (header?.kind == KotlinClassHeader.Kind.FILE_FACADE || header?.kind == KotlinClassHeader.Kind.MULTIFILE_CLASS) {
|
||||
val packageView = module.getPackage(LoadDescriptorUtil.TEST_PACKAGE_FQNAME)
|
||||
if (!packageScopes.contains(packageView.memberScope)) {
|
||||
packageScopes.add(packageView.memberScope)
|
||||
|
||||
+1
-4
@@ -29,7 +29,6 @@ import java.util.Set;
|
||||
|
||||
public final class JvmAnnotationNames {
|
||||
public static final FqName KOTLIN_CLASS = new FqName("kotlin.jvm.internal.KotlinClass");
|
||||
public static final FqName KOTLIN_PACKAGE = new FqName("kotlin.jvm.internal.KotlinPackage");
|
||||
public static final FqName KOTLIN_FILE_FACADE = new FqName("kotlin.jvm.internal.KotlinFileFacade");
|
||||
public static final FqName KOTLIN_MULTIFILE_CLASS = new FqName("kotlin.jvm.internal.KotlinMultifileClass");
|
||||
public static final FqName KOTLIN_MULTIFILE_CLASS_PART = new FqName("kotlin.jvm.internal.KotlinMultifileClassPart");
|
||||
@@ -81,9 +80,7 @@ public final class JvmAnnotationNames {
|
||||
private static final Set<JvmClassName> NULLABILITY_ANNOTATIONS = new HashSet<JvmClassName>();
|
||||
private static final Set<JvmClassName> SPECIAL_META_ANNOTATIONS = new HashSet<JvmClassName>();
|
||||
static {
|
||||
for (FqName fqName : Arrays.asList(
|
||||
KOTLIN_CLASS, KOTLIN_PACKAGE, KOTLIN_SYNTHETIC_CLASS, KOTLIN_INTERFACE_DEFAULT_IMPLS, KOTLIN_LOCAL_CLASS
|
||||
)) {
|
||||
for (FqName fqName : Arrays.asList(KOTLIN_CLASS, KOTLIN_SYNTHETIC_CLASS, KOTLIN_INTERFACE_DEFAULT_IMPLS, KOTLIN_LOCAL_CLASS)) {
|
||||
SPECIAL_ANNOTATIONS.add(JvmClassName.byFqNameWithoutInnerClasses(fqName));
|
||||
}
|
||||
|
||||
|
||||
-6
@@ -22,8 +22,6 @@ import org.jetbrains.kotlin.load.java.lazy.LazyJavaResolverContext
|
||||
import org.jetbrains.kotlin.load.java.structure.JavaClass
|
||||
import org.jetbrains.kotlin.load.java.structure.JavaPackage
|
||||
import org.jetbrains.kotlin.load.kotlin.KotlinJvmBinaryPackageSourceElement
|
||||
import org.jetbrains.kotlin.load.kotlin.KotlinJvmBinarySourceElement
|
||||
import org.jetbrains.kotlin.load.kotlin.PackageClassUtils
|
||||
import org.jetbrains.kotlin.name.ClassId
|
||||
import org.jetbrains.kotlin.name.Name
|
||||
import org.jetbrains.kotlin.storage.getValue
|
||||
@@ -39,10 +37,6 @@ class LazyJavaPackageFragment(
|
||||
LazyJavaClassDescriptor(c, this, javaClass.fqName!!, javaClass)
|
||||
}
|
||||
|
||||
internal val oldPackageFacade by c.storageManager.createNullableLazyValue {
|
||||
c.components.kotlinClassFinder.findKotlinClass(PackageClassUtils.getPackageClassId(fqName))
|
||||
}
|
||||
|
||||
internal val kotlinBinaryClasses by c.storageManager.createLazyValue {
|
||||
val simpleNames = c.components.packageMapper.findPackageParts(fqName.asString())
|
||||
simpleNames.map {
|
||||
|
||||
+6
-19
@@ -25,13 +25,12 @@ import org.jetbrains.kotlin.load.java.lazy.LazyJavaResolverContext
|
||||
import org.jetbrains.kotlin.load.java.lazy.resolveKotlinBinaryClass
|
||||
import org.jetbrains.kotlin.load.java.structure.JavaClass
|
||||
import org.jetbrains.kotlin.load.java.structure.JavaPackage
|
||||
import org.jetbrains.kotlin.load.kotlin.DeserializedDescriptorResolver
|
||||
import org.jetbrains.kotlin.load.kotlin.header.KotlinClassHeader
|
||||
import org.jetbrains.kotlin.name.ClassId
|
||||
import org.jetbrains.kotlin.name.Name
|
||||
import org.jetbrains.kotlin.name.SpecialNames
|
||||
import org.jetbrains.kotlin.resolve.scopes.DescriptorKindFilter
|
||||
import org.jetbrains.kotlin.resolve.scopes.MemberScope
|
||||
import org.jetbrains.kotlin.storage.getValue
|
||||
|
||||
public class LazyJavaPackageScope(
|
||||
c: LazyJavaResolverContext,
|
||||
@@ -62,20 +61,8 @@ public class LazyJavaPackageScope(
|
||||
public fun getFacadeSimpleNameForPartSimpleName(partName: String): String? =
|
||||
partToFacade()[partName]
|
||||
|
||||
private val deserializedPackageScope = c.storageManager.createLazyValue {
|
||||
if (ownerDescriptor.kotlinBinaryClasses.isEmpty()) {
|
||||
// If the scope is queried but no package parts are found, there's a possibility that we're trying to load symbols
|
||||
// from an old package with the binary-incompatible facade.
|
||||
// We try to read the old package facade if there is one, to report the "incompatible ABI version" message.
|
||||
ownerDescriptor.oldPackageFacade?.let { binaryClass ->
|
||||
c.components.deserializedDescriptorResolver.readData(binaryClass, DeserializedDescriptorResolver.KOTLIN_PACKAGE_FACADE)
|
||||
}
|
||||
|
||||
MemberScope.Empty
|
||||
}
|
||||
else {
|
||||
c.components.deserializedDescriptorResolver.createKotlinPackageScope(ownerDescriptor, ownerDescriptor.kotlinBinaryClasses)
|
||||
}
|
||||
private val deserializedPackageScope by c.storageManager.createLazyValue {
|
||||
c.components.deserializedDescriptorResolver.createKotlinPackageScope(ownerDescriptor, ownerDescriptor.kotlinBinaryClasses)
|
||||
}
|
||||
|
||||
private val classes = c.storageManager.createMemoizedFunctionWithNullableValues<Name, ClassDescriptor> { name ->
|
||||
@@ -107,19 +94,19 @@ public class LazyJavaPackageScope(
|
||||
override fun getContributedVariables(name: Name, location: LookupLocation): Collection<PropertyDescriptor> {
|
||||
// We should track lookups here because this scope can be used for kotlin packages too (if it doesn't contain toplevel properties nor functions).
|
||||
recordLookup(name, location)
|
||||
return deserializedPackageScope().getContributedVariables(name, NoLookupLocation.FOR_ALREADY_TRACKED)
|
||||
return deserializedPackageScope.getContributedVariables(name, NoLookupLocation.FOR_ALREADY_TRACKED)
|
||||
}
|
||||
|
||||
override fun getContributedFunctions(name: Name, location: LookupLocation): List<FunctionDescriptor> {
|
||||
// We should track lookups here because this scope can be used for kotlin packages too (if it doesn't contain toplevel properties nor functions).
|
||||
recordLookup(name, location)
|
||||
return deserializedPackageScope().getContributedFunctions(name, NoLookupLocation.FOR_ALREADY_TRACKED) + super.getContributedFunctions(name, NoLookupLocation.FOR_ALREADY_TRACKED)
|
||||
return deserializedPackageScope.getContributedFunctions(name, NoLookupLocation.FOR_ALREADY_TRACKED) + super.getContributedFunctions(name, NoLookupLocation.FOR_ALREADY_TRACKED)
|
||||
}
|
||||
|
||||
override fun addExtraDescriptors(result: MutableSet<DeclarationDescriptor>,
|
||||
kindFilter: DescriptorKindFilter,
|
||||
nameFilter: (Name) -> Boolean) {
|
||||
result.addAll(deserializedPackageScope().getContributedDescriptors(kindFilter, nameFilter))
|
||||
result.addAll(deserializedPackageScope.getContributedDescriptors(kindFilter, nameFilter))
|
||||
}
|
||||
|
||||
override fun computeMemberIndex(): MemberIndex = object : MemberIndex by EMPTY_MEMBER_INDEX {
|
||||
|
||||
+5
-3
@@ -45,7 +45,6 @@ public final class DeserializedDescriptorResolver {
|
||||
|
||||
public static final Set<KotlinClassHeader.Kind> KOTLIN_CLASS = setOf(CLASS);
|
||||
public static final Set<KotlinClassHeader.Kind> KOTLIN_FILE_FACADE_OR_MULTIFILE_CLASS_PART = setOf(FILE_FACADE, MULTIFILE_CLASS_PART);
|
||||
public static final Set<KotlinClassHeader.Kind> KOTLIN_PACKAGE_FACADE = setOf(PACKAGE_FACADE);
|
||||
|
||||
public DeserializedDescriptorResolver(@NotNull ErrorReporter errorReporter) {
|
||||
this.errorReporter = errorReporter;
|
||||
@@ -95,8 +94,11 @@ public final class DeserializedDescriptorResolver {
|
||||
}
|
||||
|
||||
@NotNull
|
||||
public MemberScope createKotlinPackageScope(@NotNull PackageFragmentDescriptor descriptor, @NotNull List<KotlinJvmBinaryClass> packageParts) {
|
||||
List<MemberScope> list = new ArrayList<MemberScope>();
|
||||
public MemberScope createKotlinPackageScope(
|
||||
@NotNull PackageFragmentDescriptor descriptor,
|
||||
@NotNull List<KotlinJvmBinaryClass> packageParts
|
||||
) {
|
||||
List<MemberScope> list = new ArrayList<MemberScope>(packageParts.size());
|
||||
for (KotlinJvmBinaryClass callable : packageParts) {
|
||||
MemberScope scope = createKotlinPackagePartScope(descriptor, callable);
|
||||
if (scope != null) {
|
||||
|
||||
-2
@@ -34,7 +34,6 @@ class KotlinClassHeader(
|
||||
|
||||
enum class Kind {
|
||||
CLASS,
|
||||
PACKAGE_FACADE,
|
||||
FILE_FACADE,
|
||||
MULTIFILE_CLASS,
|
||||
MULTIFILE_CLASS_PART,
|
||||
@@ -49,7 +48,6 @@ class KotlinClassHeader(
|
||||
}
|
||||
|
||||
fun KotlinClassHeader.isCompatibleClassKind(): Boolean = isCompatibleAbiVersion && kind == KotlinClassHeader.Kind.CLASS
|
||||
fun KotlinClassHeader.isCompatiblePackageFacadeKind(): Boolean = isCompatibleAbiVersion && kind == KotlinClassHeader.Kind.PACKAGE_FACADE
|
||||
fun KotlinClassHeader.isCompatibleFileFacadeKind(): Boolean = isCompatibleAbiVersion && kind == KotlinClassHeader.Kind.FILE_FACADE
|
||||
fun KotlinClassHeader.isCompatibleMultifileClassKind(): Boolean = isCompatibleAbiVersion && kind == KotlinClassHeader.Kind.MULTIFILE_CLASS
|
||||
fun KotlinClassHeader.isCompatibleMultifileClassPartKind(): Boolean = isCompatibleAbiVersion && kind == KotlinClassHeader.Kind.MULTIFILE_CLASS_PART
|
||||
|
||||
-3
@@ -39,7 +39,6 @@ public class ReadKotlinClassHeaderAnnotationVisitor implements AnnotationVisitor
|
||||
|
||||
static {
|
||||
HEADER_KINDS.put(ClassId.topLevel(KOTLIN_CLASS), CLASS);
|
||||
HEADER_KINDS.put(ClassId.topLevel(KOTLIN_PACKAGE), PACKAGE_FACADE);
|
||||
HEADER_KINDS.put(ClassId.topLevel(KOTLIN_FILE_FACADE), FILE_FACADE);
|
||||
HEADER_KINDS.put(ClassId.topLevel(KOTLIN_MULTIFILE_CLASS), MULTIFILE_CLASS);
|
||||
HEADER_KINDS.put(ClassId.topLevel(KOTLIN_MULTIFILE_CLASS_PART), MULTIFILE_CLASS_PART);
|
||||
@@ -79,7 +78,6 @@ public class ReadKotlinClassHeaderAnnotationVisitor implements AnnotationVisitor
|
||||
|
||||
private boolean shouldHaveData() {
|
||||
return headerKind == CLASS ||
|
||||
headerKind == PACKAGE_FACADE ||
|
||||
headerKind == FILE_FACADE ||
|
||||
headerKind == MULTIFILE_CLASS_PART;
|
||||
}
|
||||
@@ -108,7 +106,6 @@ public class ReadKotlinClassHeaderAnnotationVisitor implements AnnotationVisitor
|
||||
|
||||
switch (newKind) {
|
||||
case CLASS:
|
||||
case PACKAGE_FACADE:
|
||||
case FILE_FACADE:
|
||||
case MULTIFILE_CLASS:
|
||||
case MULTIFILE_CLASS_PART:
|
||||
|
||||
@@ -23,7 +23,6 @@ import org.jetbrains.kotlin.incremental.components.NoLookupLocation
|
||||
import org.jetbrains.kotlin.load.java.structure.reflect.classId
|
||||
import org.jetbrains.kotlin.name.Name
|
||||
import org.jetbrains.kotlin.resolve.scopes.MemberScope
|
||||
import kotlin.jvm.internal.KotlinPackage
|
||||
import kotlin.reflect.KCallable
|
||||
|
||||
internal class KPackageImpl(override val jClass: Class<*>, val moduleName: String) : KDeclarationContainerImpl() {
|
||||
@@ -55,10 +54,7 @@ internal class KPackageImpl(override val jClass: Class<*>, val moduleName: Strin
|
||||
jClass.hashCode()
|
||||
|
||||
override fun toString(): String {
|
||||
val name = jClass.name
|
||||
return "package " + if (jClass.isAnnotationPresent(KotlinPackage::class.java)) {
|
||||
if (name == "_DefaultPackage") "<default>" else name.substringBeforeLast(".")
|
||||
}
|
||||
else name
|
||||
val fqName = jClass.classId.packageFqName
|
||||
return "package " + (if (fqName.isRoot) "<default>" else fqName.asString())
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,35 +0,0 @@
|
||||
/*
|
||||
* Copyright 2010-2015 JetBrains s.r.o.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
package kotlin.jvm.internal;
|
||||
|
||||
import java.lang.annotation.ElementType;
|
||||
import java.lang.annotation.Retention;
|
||||
import java.lang.annotation.RetentionPolicy;
|
||||
import java.lang.annotation.Target;
|
||||
|
||||
@Retention(RetentionPolicy.RUNTIME)
|
||||
@Target(ElementType.TYPE)
|
||||
public @interface KotlinPackage {
|
||||
@Deprecated
|
||||
int abiVersion() default 32;
|
||||
|
||||
int[] version() default {};
|
||||
|
||||
String[] data();
|
||||
|
||||
String[] strings();
|
||||
}
|
||||
-6
@@ -31,7 +31,6 @@ import org.jetbrains.kotlin.load.kotlin.KotlinBinaryClassCache
|
||||
import org.jetbrains.kotlin.load.kotlin.header.isCompatibleClassKind
|
||||
import org.jetbrains.kotlin.load.kotlin.header.isCompatibleFileFacadeKind
|
||||
import org.jetbrains.kotlin.load.kotlin.header.isCompatibleMultifileClassKind
|
||||
import org.jetbrains.kotlin.load.kotlin.header.isCompatiblePackageFacadeKind
|
||||
import org.jetbrains.kotlin.name.FqName
|
||||
import org.jetbrains.kotlin.psi.KtFile
|
||||
import org.jetbrains.kotlin.serialization.deserialization.TypeTable
|
||||
@@ -76,11 +75,6 @@ public open class KotlinClsStubBuilder : ClsStubBuilder() {
|
||||
return null
|
||||
}
|
||||
return when {
|
||||
header.isCompatiblePackageFacadeKind() -> {
|
||||
val (nameResolver, packageProto) = JvmProtoBufUtil.readPackageDataFrom(annotationData, strings)
|
||||
val context = components.createContext(nameResolver, packageFqName, TypeTable(packageProto.typeTable))
|
||||
createPackageFacadeStub(packageProto, packageFqName, context)
|
||||
}
|
||||
header.isCompatibleClassKind() -> {
|
||||
if (header.isLocalClass) return null
|
||||
val (nameResolver, classProto) = JvmProtoBufUtil.readClassDataFrom(annotationData, strings)
|
||||
|
||||
+3
-3
@@ -27,9 +27,10 @@ import org.jetbrains.kotlin.load.kotlin.PackageClassUtils
|
||||
import org.jetbrains.kotlin.load.kotlin.header.isCompatibleClassKind
|
||||
import org.jetbrains.kotlin.load.kotlin.header.isCompatibleFileFacadeKind
|
||||
import org.jetbrains.kotlin.load.kotlin.header.isCompatibleMultifileClassKind
|
||||
import org.jetbrains.kotlin.load.kotlin.header.isCompatiblePackageFacadeKind
|
||||
import org.jetbrains.kotlin.name.FqName
|
||||
import org.jetbrains.kotlin.renderer.*
|
||||
import org.jetbrains.kotlin.renderer.DescriptorRenderer
|
||||
import org.jetbrains.kotlin.renderer.DescriptorRendererModifier
|
||||
import org.jetbrains.kotlin.renderer.ExcludedTypeAnnotations
|
||||
import org.jetbrains.kotlin.resolve.DescriptorUtils.isEnumEntry
|
||||
import org.jetbrains.kotlin.resolve.dataClassUtils.isComponentLike
|
||||
import org.jetbrains.kotlin.resolve.descriptorUtil.secondaryConstructors
|
||||
@@ -66,7 +67,6 @@ public fun buildDecompiledText(
|
||||
.replace(FILE_ABI_VERSION_MARKER, classHeader.version.toString()),
|
||||
mapOf())
|
||||
}
|
||||
classHeader.isCompatiblePackageFacadeKind(),
|
||||
classHeader.isCompatibleFileFacadeKind() ->
|
||||
buildDecompiledText(packageFqName, ArrayList(resolver.resolveDeclarationsInFacade(classId.asSingleFqName())))
|
||||
classHeader.isCompatibleClassKind() ->
|
||||
|
||||
@@ -41,7 +41,6 @@ public object KotlinAbiVersionIndex : KotlinAbiVersionIndexBase<KotlinAbiVersion
|
||||
|
||||
private val kotlinAnnotationsDesc = setOf(
|
||||
KOTLIN_CLASS,
|
||||
KOTLIN_PACKAGE,
|
||||
KOTLIN_FILE_FACADE,
|
||||
KOTLIN_MULTIFILE_CLASS
|
||||
).map { asmDescByFqNameWithoutInnerClasses(it) }
|
||||
|
||||
+1
-1
@@ -24,7 +24,7 @@ import org.jetbrains.kotlin.test.KotlinTestUtils
|
||||
|
||||
class ClsStubBuilderForWrongAbiVersionTest : AbstractClsStubBuilderTest() {
|
||||
|
||||
fun testPackage() = testStubsForFileWithWrongAbiVersion("WrongPackage")
|
||||
fun testPackage() = testStubsForFileWithWrongAbiVersion("Wrong_packageKt")
|
||||
|
||||
fun testClass() = testStubsForFileWithWrongAbiVersion("ClassWithWrongAbiVersion")
|
||||
|
||||
|
||||
+1
-1
@@ -38,7 +38,7 @@ public class DecompiledTextForWrongAbiVersionTest : AbstractInternalCompiledClas
|
||||
|
||||
fun testClassWithWrongAbiVersion() = doTest("ClassWithWrongAbiVersion")
|
||||
|
||||
fun testPackageFacadeWithWrongAbiVersion() = doTest("WrongPackage")
|
||||
fun testPackagePartWithWrongAbiVersion() = doTest("Wrong_packageKt")
|
||||
|
||||
fun doTest(name: String) {
|
||||
val root = NavigateToDecompiledLibraryTest.findTestLibraryRoot(myModule!!)!!
|
||||
|
||||
@@ -58,7 +58,6 @@ import org.jetbrains.kotlin.jps.JpsKotlinCompilerSettings
|
||||
import org.jetbrains.kotlin.jps.incremental.*
|
||||
import org.jetbrains.kotlin.load.kotlin.ModuleMapping
|
||||
import org.jetbrains.kotlin.load.kotlin.PackageClassUtils
|
||||
import org.jetbrains.kotlin.load.kotlin.header.isCompatiblePackageFacadeKind
|
||||
import org.jetbrains.kotlin.load.kotlin.incremental.components.IncrementalCache
|
||||
import org.jetbrains.kotlin.load.kotlin.incremental.components.IncrementalCompilationComponents
|
||||
import org.jetbrains.kotlin.modules.TargetId
|
||||
@@ -421,10 +420,7 @@ public class KotlinBuilder : ModuleLevelBuilder(BuilderCategory.SOURCE_PROCESSOR
|
||||
fun getOldSourceFiles(generatedClass: GeneratedJvmClass, previousMappings: Mappings): Collection<File> {
|
||||
if (!generatedClass.outputFile.getName().endsWith(PackageClassUtils.PACKAGE_CLASS_NAME_SUFFIX + ".class")) return emptySet()
|
||||
|
||||
val kotlinClass = generatedClass.outputClass
|
||||
if (!kotlinClass.getClassHeader().isCompatiblePackageFacadeKind()) return emptySet()
|
||||
|
||||
val classInternalName = JvmClassName.byClassId(kotlinClass.getClassId()).getInternalName()
|
||||
val classInternalName = JvmClassName.byClassId(generatedClass.outputClass.getClassId()).getInternalName()
|
||||
val oldClassSources = previousMappings.getClassSources(previousMappings.getName(classInternalName))
|
||||
if (oldClassSources == null) return emptySet()
|
||||
|
||||
|
||||
@@ -36,7 +36,10 @@ import org.jetbrains.kotlin.jps.build.GeneratedJvmClass
|
||||
import org.jetbrains.kotlin.jps.build.KotlinBuilder
|
||||
import org.jetbrains.kotlin.jps.incremental.storage.*
|
||||
import org.jetbrains.kotlin.load.kotlin.ModuleMapping
|
||||
import org.jetbrains.kotlin.load.kotlin.header.*
|
||||
import org.jetbrains.kotlin.load.kotlin.header.isCompatibleClassKind
|
||||
import org.jetbrains.kotlin.load.kotlin.header.isCompatibleFileFacadeKind
|
||||
import org.jetbrains.kotlin.load.kotlin.header.isCompatibleMultifileClassKind
|
||||
import org.jetbrains.kotlin.load.kotlin.header.isCompatibleMultifileClassPartKind
|
||||
import org.jetbrains.kotlin.load.kotlin.incremental.components.IncrementalCache
|
||||
import org.jetbrains.kotlin.load.kotlin.incremental.components.JvmPackagePartProto
|
||||
import org.jetbrains.kotlin.name.FqName
|
||||
@@ -165,24 +168,20 @@ public class IncrementalCacheImpl(
|
||||
|
||||
val header = kotlinClass.classHeader
|
||||
val changesInfo = when {
|
||||
header.isCompatiblePackageFacadeKind() ->
|
||||
protoMap.process(kotlinClass, isPackage = true)
|
||||
header.isCompatibleFileFacadeKind() -> {
|
||||
assert(sourceFiles.size() == 1) { "Package part from several source files: $sourceFiles" }
|
||||
packagePartMap.addPackagePart(className)
|
||||
|
||||
val isPackage = true
|
||||
|
||||
protoMap.process(kotlinClass, isPackage) +
|
||||
protoMap.process(kotlinClass, isPackage = true) +
|
||||
constantsMap.process(kotlinClass) +
|
||||
inlineFunctionsMap.process(kotlinClass, isPackage)
|
||||
inlineFunctionsMap.process(kotlinClass, isPackage = true)
|
||||
}
|
||||
header.isCompatibleMultifileClassKind() -> {
|
||||
val partNames = kotlinClass.classHeader.filePartClassNames?.toList()
|
||||
?: throw AssertionError("Multifile class has no parts: ${kotlinClass.className}")
|
||||
multifileClassFacadeMap.add(className, partNames)
|
||||
|
||||
// TODO NO_CHANGES? (delegates only, see package facade)
|
||||
// TODO NO_CHANGES? (delegates only)
|
||||
constantsMap.process(kotlinClass) +
|
||||
inlineFunctionsMap.process(kotlinClass, isPackage = true)
|
||||
}
|
||||
@@ -191,18 +190,14 @@ public class IncrementalCacheImpl(
|
||||
packagePartMap.addPackagePart(className)
|
||||
multifileClassPartMap.add(className.internalName, header.multifileClassName!!)
|
||||
|
||||
val isPackage = true
|
||||
|
||||
protoMap.process(kotlinClass, isPackage) +
|
||||
protoMap.process(kotlinClass, isPackage = true) +
|
||||
constantsMap.process(kotlinClass) +
|
||||
inlineFunctionsMap.process(kotlinClass, isPackage)
|
||||
inlineFunctionsMap.process(kotlinClass, isPackage = true)
|
||||
}
|
||||
header.isCompatibleClassKind() && !header.isLocalClass -> {
|
||||
val isPackage = false
|
||||
|
||||
protoMap.process(kotlinClass, isPackage) +
|
||||
protoMap.process(kotlinClass, isPackage = false) +
|
||||
constantsMap.process(kotlinClass) +
|
||||
inlineFunctionsMap.process(kotlinClass, isPackage)
|
||||
inlineFunctionsMap.process(kotlinClass, isPackage = false)
|
||||
}
|
||||
else -> CompilationResult.NO_CHANGES
|
||||
}
|
||||
@@ -674,7 +669,7 @@ data class CompilationResult(
|
||||
public val NO_CHANGES: CompilationResult = CompilationResult()
|
||||
}
|
||||
|
||||
public operator fun plus(other: CompilationResult): CompilationResult =
|
||||
operator fun plus(other: CompilationResult): CompilationResult =
|
||||
CompilationResult(protoChanged || other.protoChanged,
|
||||
constantsChanged || other.constantsChanged,
|
||||
inlineChanged || other.inlineChanged,
|
||||
|
||||
+4
-4
@@ -22,7 +22,9 @@ import com.google.common.io.Files
|
||||
import com.google.protobuf.ExtensionRegistry
|
||||
import com.intellij.openapi.util.io.FileUtil
|
||||
import org.jetbrains.kotlin.jps.incremental.LocalFileKotlinClass
|
||||
import org.jetbrains.kotlin.load.kotlin.header.*
|
||||
import org.jetbrains.kotlin.load.kotlin.header.isCompatibleClassKind
|
||||
import org.jetbrains.kotlin.load.kotlin.header.isCompatibleFileFacadeKind
|
||||
import org.jetbrains.kotlin.load.kotlin.header.isCompatibleMultifileClassPartKind
|
||||
import org.jetbrains.kotlin.serialization.DebugProtoBuf
|
||||
import org.jetbrains.kotlin.serialization.jvm.BitEncoding
|
||||
import org.jetbrains.kotlin.serialization.jvm.DebugJvmProtoBuf
|
||||
@@ -140,9 +142,7 @@ fun classFileToString(classFile: File): String {
|
||||
out.write("\n------ string table types proto -----\n${DebugJvmProtoBuf.StringTableTypes.parseDelimitedFrom(input)}")
|
||||
|
||||
when {
|
||||
classHeader!!.isCompatiblePackageFacadeKind() ->
|
||||
out.write("\n------ package proto -----\n${DebugProtoBuf.Package.parseFrom(input, getExtensionRegistry())}")
|
||||
classHeader.isCompatibleFileFacadeKind() ->
|
||||
classHeader!!.isCompatibleFileFacadeKind() ->
|
||||
out.write("\n------ file facade proto -----\n${DebugProtoBuf.Package.parseFrom(input, getExtensionRegistry())}")
|
||||
classHeader.isCompatibleClassKind() ->
|
||||
out.write("\n------ class proto -----\n${DebugProtoBuf.Class.parseFrom(input, getExtensionRegistry())}")
|
||||
|
||||
@@ -22,7 +22,6 @@ import org.jetbrains.kotlin.jps.incremental.storage.ProtoMapValue
|
||||
import org.jetbrains.kotlin.load.kotlin.header.isCompatibleClassKind
|
||||
import org.jetbrains.kotlin.load.kotlin.header.isCompatibleFileFacadeKind
|
||||
import org.jetbrains.kotlin.load.kotlin.header.isCompatibleMultifileClassPartKind
|
||||
import org.jetbrains.kotlin.load.kotlin.header.isCompatiblePackageFacadeKind
|
||||
import org.jetbrains.kotlin.serialization.jvm.BitEncoding
|
||||
import org.jetbrains.kotlin.test.KotlinTestUtils
|
||||
import org.jetbrains.kotlin.test.MockLibraryUtil
|
||||
@@ -94,16 +93,15 @@ public abstract class AbstractProtoComparisonTest : UsefulTestCase() {
|
||||
val newProtoBytes = BitEncoding.decodeBytes(newClassHeader.annotationData!!)
|
||||
|
||||
val oldProto = ProtoMapValue(
|
||||
oldClassHeader.isCompatiblePackageFacadeKind() || oldClassHeader.isCompatibleFileFacadeKind() || oldClassHeader.isCompatibleMultifileClassPartKind(),
|
||||
oldClassHeader.isCompatibleFileFacadeKind() || oldClassHeader.isCompatibleMultifileClassPartKind(),
|
||||
oldProtoBytes, oldClassHeader.strings!!
|
||||
)
|
||||
val newProto = ProtoMapValue(
|
||||
newClassHeader.isCompatiblePackageFacadeKind() || newClassHeader.isCompatibleFileFacadeKind() || newClassHeader.isCompatibleMultifileClassPartKind(),
|
||||
newClassHeader.isCompatibleFileFacadeKind() || newClassHeader.isCompatibleMultifileClassPartKind(),
|
||||
newProtoBytes, newClassHeader.strings!!
|
||||
)
|
||||
|
||||
val diff = when {
|
||||
newClassHeader.isCompatiblePackageFacadeKind(),
|
||||
newClassHeader.isCompatibleClassKind(),
|
||||
newClassHeader.isCompatibleFileFacadeKind(),
|
||||
newClassHeader.isCompatibleMultifileClassPartKind() ->
|
||||
|
||||
Reference in New Issue
Block a user