Remove kotlin.jvm.internal.KotlinPackage and corresponding code

This commit is contained in:
Alexander Udalov
2015-11-20 16:20:05 +03:00
parent ad6888dac6
commit 8594cfca46
31 changed files with 63 additions and 182 deletions
@@ -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));
}
@@ -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 {
@@ -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 {
@@ -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) {
@@ -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
@@ -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: