Removed MemberScope.ownerDescriptor
This commit is contained in:
+2
-5
@@ -61,9 +61,9 @@ import java.util.*
|
||||
|
||||
public class LazyJavaClassMemberScope(
|
||||
c: LazyJavaResolverContext,
|
||||
containingDeclaration: ClassDescriptor,
|
||||
override val ownerDescriptor: ClassDescriptor,
|
||||
private val jClass: JavaClass
|
||||
) : LazyJavaScope(c, containingDeclaration) {
|
||||
) : LazyJavaScope(c) {
|
||||
|
||||
override fun computeMemberIndex(): MemberIndex {
|
||||
return object : ClassMemberIndex(jClass, { !it.isStatic() }) {
|
||||
@@ -634,9 +634,6 @@ public class LazyJavaClassMemberScope(
|
||||
}
|
||||
}
|
||||
|
||||
override val ownerDescriptor: ClassDescriptor
|
||||
get() = super.ownerDescriptor as ClassDescriptor
|
||||
|
||||
// namespaces should be resolved elsewhere
|
||||
override fun getPackage(name: Name) = null
|
||||
|
||||
|
||||
+11
-12
@@ -36,11 +36,12 @@ import org.jetbrains.kotlin.resolve.scopes.MemberScope
|
||||
public class LazyJavaPackageScope(
|
||||
c: LazyJavaResolverContext,
|
||||
private val jPackage: JavaPackage,
|
||||
private val containingDeclaration: LazyJavaPackageFragment
|
||||
) : LazyJavaStaticScope(c, containingDeclaration) {
|
||||
override val ownerDescriptor: LazyJavaPackageFragment
|
||||
) : LazyJavaStaticScope(c) {
|
||||
|
||||
private val partToFacade = c.storageManager.createLazyValue {
|
||||
val result = hashMapOf<String, String>()
|
||||
kotlinClasses@for (kotlinClass in containingDeclaration.kotlinBinaryClasses) {
|
||||
kotlinClasses@for (kotlinClass in ownerDescriptor.kotlinBinaryClasses) {
|
||||
val header = kotlinClass.classHeader
|
||||
when (header.kind) {
|
||||
KotlinClassHeader.Kind.MULTIFILE_CLASS_PART -> {
|
||||
@@ -62,25 +63,23 @@ public class LazyJavaPackageScope(
|
||||
partToFacade()[partName]
|
||||
|
||||
private val deserializedPackageScope = c.storageManager.createLazyValue {
|
||||
if (containingDeclaration.kotlinBinaryClasses.isEmpty()) {
|
||||
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.
|
||||
packageFragment.oldPackageFacade?.let { binaryClass ->
|
||||
ownerDescriptor.oldPackageFacade?.let { binaryClass ->
|
||||
c.components.deserializedDescriptorResolver.readData(binaryClass, DeserializedDescriptorResolver.KOTLIN_PACKAGE_FACADE)
|
||||
}
|
||||
|
||||
MemberScope.empty(packageFragment)
|
||||
MemberScope.Empty
|
||||
}
|
||||
else {
|
||||
c.components.deserializedDescriptorResolver.createKotlinPackageScope(packageFragment, containingDeclaration.kotlinBinaryClasses)
|
||||
c.components.deserializedDescriptorResolver.createKotlinPackageScope(ownerDescriptor, ownerDescriptor.kotlinBinaryClasses)
|
||||
}
|
||||
}
|
||||
|
||||
private val packageFragment: LazyJavaPackageFragment get() = ownerDescriptor as LazyJavaPackageFragment
|
||||
|
||||
private val classes = c.storageManager.createMemoizedFunctionWithNullableValues<Name, ClassDescriptor> { name ->
|
||||
val classId = ClassId(packageFragment.fqName, name)
|
||||
val classId = ClassId(ownerDescriptor.fqName, name)
|
||||
|
||||
val kotlinResult = c.resolveKotlinBinaryClass(c.components.kotlinClassFinder.findKotlinClass(classId))
|
||||
when (kotlinResult) {
|
||||
@@ -89,8 +88,8 @@ public class LazyJavaPackageScope(
|
||||
is KotlinClassLookupResult.NotFound -> {
|
||||
c.components.finder.findClass(classId)?.let { javaClass ->
|
||||
c.javaClassResolver.resolveClass(javaClass).apply {
|
||||
assert(this == null || this.containingDeclaration == packageFragment) {
|
||||
"Wrong package fragment for $this, expected $packageFragment"
|
||||
assert(this == null || this.containingDeclaration == ownerDescriptor) {
|
||||
"Wrong package fragment for $this, expected $ownerDescriptor"
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
+3
-4
@@ -51,10 +51,9 @@ import org.jetbrains.kotlin.utils.addIfNotNull
|
||||
import org.jetbrains.kotlin.utils.toReadOnlyList
|
||||
import java.util.*
|
||||
|
||||
public abstract class LazyJavaScope(
|
||||
protected val c: LazyJavaResolverContext,
|
||||
override val ownerDescriptor: DeclarationDescriptor
|
||||
) : MemberScopeImpl() {
|
||||
public abstract class LazyJavaScope(protected val c: LazyJavaResolverContext) : MemberScopeImpl() {
|
||||
protected abstract val ownerDescriptor: DeclarationDescriptor
|
||||
|
||||
// this lazy value is not used at all in LazyPackageFragmentScopeForJavaPackage because we do not use caching there
|
||||
// but is placed in the base class to not duplicate code
|
||||
private val allDescriptors = c.storageManager.createRecursionTolerantLazyValue<Collection<DeclarationDescriptor>>(
|
||||
|
||||
+2
-5
@@ -36,8 +36,8 @@ import org.jetbrains.kotlin.types.KotlinType
|
||||
public class LazyJavaStaticClassScope(
|
||||
c: LazyJavaResolverContext,
|
||||
private val jClass: JavaClass,
|
||||
descriptor: LazyJavaClassDescriptor
|
||||
) : LazyJavaStaticScope(c, descriptor) {
|
||||
override val ownerDescriptor: LazyJavaClassDescriptor
|
||||
) : LazyJavaStaticScope(c) {
|
||||
|
||||
override fun computeMemberIndex(): MemberIndex {
|
||||
val delegate = ClassMemberIndex(jClass) { it.isStatic() }
|
||||
@@ -110,9 +110,6 @@ public class LazyJavaStaticClassScope(
|
||||
}
|
||||
}
|
||||
|
||||
override val ownerDescriptor: LazyJavaClassDescriptor
|
||||
get() = super.ownerDescriptor as LazyJavaClassDescriptor
|
||||
|
||||
private fun getStaticFunctionsFromJavaSuperClasses(name: Name, descriptor: ClassDescriptor): Set<SimpleFunctionDescriptor> {
|
||||
val staticScope = descriptor.getParentJavaStaticClassScope() ?: return emptySet()
|
||||
return staticScope.getContributedFunctions(name, NoLookupLocation.WHEN_GET_SUPER_MEMBERS).map { it as SimpleFunctionDescriptor }.toSet()
|
||||
|
||||
+1
-5
@@ -16,7 +16,6 @@
|
||||
|
||||
package org.jetbrains.kotlin.load.java.lazy.descriptors
|
||||
|
||||
import org.jetbrains.kotlin.descriptors.ClassOrPackageFragmentDescriptor
|
||||
import org.jetbrains.kotlin.descriptors.PropertyDescriptor
|
||||
import org.jetbrains.kotlin.descriptors.TypeParameterDescriptor
|
||||
import org.jetbrains.kotlin.load.java.lazy.LazyJavaResolverContext
|
||||
@@ -25,10 +24,7 @@ import org.jetbrains.kotlin.name.FqName
|
||||
import org.jetbrains.kotlin.name.Name
|
||||
import org.jetbrains.kotlin.types.KotlinType
|
||||
|
||||
public abstract class LazyJavaStaticScope(
|
||||
c: LazyJavaResolverContext,
|
||||
descriptor: ClassOrPackageFragmentDescriptor
|
||||
) : LazyJavaScope(c, descriptor) {
|
||||
public abstract class LazyJavaStaticScope(c: LazyJavaResolverContext) : LazyJavaScope(c) {
|
||||
|
||||
override fun getDispatchReceiverParameter() = null
|
||||
|
||||
|
||||
+2
-2
@@ -42,7 +42,7 @@ class BuiltInClassesAreSerializableOnJvm(
|
||||
|
||||
private fun createMockJavaIoSerializableType(): KotlinType {
|
||||
val mockJavaIoPackageFragment = object : PackageFragmentDescriptorImpl(moduleDescriptor, FqName("java.io")) {
|
||||
override fun getMemberScope() = MemberScope.empty(this)
|
||||
override fun getMemberScope() = MemberScope.Empty
|
||||
}
|
||||
|
||||
//NOTE: can't reference anyType right away, because this is sometimes called when JvmBuiltIns are initializing
|
||||
@@ -56,7 +56,7 @@ class BuiltInClassesAreSerializableOnJvm(
|
||||
mockJavaIoPackageFragment, Name.identifier("Serializable"), Modality.ABSTRACT, superTypes, SourceElement.NO_SOURCE
|
||||
)
|
||||
|
||||
mockSerializableClass.initialize(MemberScope.empty(mockSerializableClass), emptySet(), null)
|
||||
mockSerializableClass.initialize(MemberScope.Empty, emptySet(), null)
|
||||
return mockSerializableClass.defaultType
|
||||
}
|
||||
|
||||
|
||||
+2
-2
@@ -104,9 +104,9 @@ public final class DeserializedDescriptorResolver {
|
||||
}
|
||||
}
|
||||
if (list.isEmpty()) {
|
||||
return MemberScope.Companion.empty(descriptor);
|
||||
return MemberScope.Empty.INSTANCE;
|
||||
}
|
||||
return new ChainedScope(descriptor, "Member scope for union of package parts data", list.toArray(new MemberScope[list.size()]));
|
||||
return new ChainedScope("Member scope for union of package parts data", list.toArray(new MemberScope[list.size()]));
|
||||
}
|
||||
|
||||
@Nullable
|
||||
|
||||
@@ -41,9 +41,6 @@ class FunctionClassScope(
|
||||
}
|
||||
}
|
||||
|
||||
override val ownerDescriptor: DeclarationDescriptor
|
||||
get() = functionClass
|
||||
|
||||
override fun getContributedDescriptors(kindFilter: DescriptorKindFilter, nameFilter: (Name) -> Boolean): Collection<DeclarationDescriptor> {
|
||||
if (!kindFilter.acceptsKinds(DescriptorKindFilter.CALLABLES.kindMask)) return listOf()
|
||||
return allDescriptors()
|
||||
@@ -76,7 +73,7 @@ class FunctionClassScope(
|
||||
}
|
||||
|
||||
override fun conflict(fromSuper: CallableMemberDescriptor, fromCurrent: CallableMemberDescriptor) {
|
||||
error("Conflict in scope of $ownerDescriptor: $fromSuper vs $fromCurrent")
|
||||
error("Conflict in scope of $functionClass: $fromSuper vs $fromCurrent")
|
||||
}
|
||||
}
|
||||
)
|
||||
|
||||
-1
@@ -84,7 +84,6 @@ public abstract class AbstractTypeParameterDescriptor extends DeclarationDescrip
|
||||
scopes.add(bound.getMemberScope());
|
||||
}
|
||||
return new ChainedScope(
|
||||
AbstractTypeParameterDescriptor.this,
|
||||
"Scope for type parameter " + name.asString(),
|
||||
scopes.toArray(new MemberScope[scopes.size()])
|
||||
);
|
||||
|
||||
-6
@@ -257,12 +257,6 @@ public class EnumEntrySyntheticClassDescriptor extends ClassDescriptorBase {
|
||||
return result;
|
||||
}
|
||||
|
||||
@NotNull
|
||||
@Override
|
||||
public DeclarationDescriptor getOwnerDescriptor() {
|
||||
return EnumEntrySyntheticClassDescriptor.this;
|
||||
}
|
||||
|
||||
@NotNull
|
||||
@Override
|
||||
public Collection<DeclarationDescriptor> getContributedDescriptors(
|
||||
|
||||
+2
-2
@@ -41,11 +41,11 @@ public class LazyPackageViewDescriptorImpl(
|
||||
|
||||
override val memberScope: MemberScope = LazyScopeAdapter(storageManager.createLazyValue {
|
||||
if (fragments.isEmpty()) {
|
||||
MemberScope.empty(this)
|
||||
MemberScope.Empty
|
||||
}
|
||||
else {
|
||||
val scopes = fragments.map { it.getMemberScope() } + SubpackagesScope(module, fqName)
|
||||
ChainedScope(this, "package view scope for $fqName in ${module.getName()}", *scopes.toTypedArray())
|
||||
ChainedScope("package view scope for $fqName in ${module.getName()}", *scopes.toTypedArray())
|
||||
}
|
||||
})
|
||||
|
||||
|
||||
@@ -26,12 +26,9 @@ import org.jetbrains.kotlin.resolve.scopes.DescriptorKindFilter
|
||||
import org.jetbrains.kotlin.resolve.scopes.MemberScopeImpl
|
||||
import org.jetbrains.kotlin.utils.Printer
|
||||
import org.jetbrains.kotlin.utils.addIfNotNull
|
||||
import org.jetbrains.kotlin.utils.sure
|
||||
import java.util.ArrayList
|
||||
import java.util.*
|
||||
|
||||
public class SubpackagesScope(private val moduleDescriptor: ModuleDescriptor, private val fqName: FqName) : MemberScopeImpl() {
|
||||
override val ownerDescriptor: DeclarationDescriptor
|
||||
get() = moduleDescriptor.getPackage(fqName)
|
||||
|
||||
override fun getPackage(name: Name): PackageViewDescriptor? {
|
||||
if (name.isSpecial()) {
|
||||
@@ -64,8 +61,6 @@ public class SubpackagesScope(private val moduleDescriptor: ModuleDescriptor, pr
|
||||
p.println(javaClass.getSimpleName(), " {")
|
||||
p.pushIndent()
|
||||
|
||||
p.println("thisDescriptor = ", ownerDescriptor)
|
||||
|
||||
p.popIndent()
|
||||
p.println("}")
|
||||
}
|
||||
|
||||
@@ -33,9 +33,6 @@ public abstract class AbstractScopeAdapter : MemberScope {
|
||||
else
|
||||
workerScope
|
||||
|
||||
override val ownerDescriptor: DeclarationDescriptor
|
||||
get() = workerScope.ownerDescriptor
|
||||
|
||||
override fun getContributedFunctions(name: Name, location: LookupLocation): Collection<FunctionDescriptor> {
|
||||
return workerScope.getContributedFunctions(name, location)
|
||||
}
|
||||
|
||||
@@ -23,16 +23,12 @@ import org.jetbrains.kotlin.util.collectionUtils.getFirstMatch
|
||||
import org.jetbrains.kotlin.util.collectionUtils.getFromAllScopes
|
||||
import org.jetbrains.kotlin.utils.Printer
|
||||
|
||||
public open class ChainedScope(
|
||||
private val descriptor: DeclarationDescriptor?/* it's nullable as a hack for TypeUtils.intersect() */,
|
||||
public class ChainedScope(
|
||||
private val debugName: String,
|
||||
vararg scopes: MemberScope
|
||||
) : MemberScope {
|
||||
private val scopeChain = scopes.clone()
|
||||
|
||||
override val ownerDescriptor: DeclarationDescriptor
|
||||
get() = descriptor!!
|
||||
|
||||
override fun getContributedClassifier(name: Name, location: LookupLocation): ClassifierDescriptor?
|
||||
= getFirstMatch(scopeChain) { it.getContributedClassifier(name, location) }
|
||||
|
||||
|
||||
@@ -17,16 +17,11 @@
|
||||
package org.jetbrains.kotlin.resolve.scopes
|
||||
|
||||
import org.jetbrains.kotlin.descriptors.ClassDescriptor
|
||||
import org.jetbrains.kotlin.descriptors.DeclarationDescriptor
|
||||
import org.jetbrains.kotlin.incremental.components.LookupLocation
|
||||
import org.jetbrains.kotlin.name.Name
|
||||
import org.jetbrains.kotlin.utils.Printer
|
||||
|
||||
public class InnerClassesScopeWrapper(val workerScope: MemberScope) : MemberScopeImpl() {
|
||||
|
||||
override val ownerDescriptor: DeclarationDescriptor
|
||||
get() = workerScope.ownerDescriptor
|
||||
|
||||
override fun getContributedClassifier(name: Name, location: LookupLocation) = workerScope.getContributedClassifier(name, location) as? ClassDescriptor
|
||||
|
||||
override fun getContributedDescriptors(kindFilter: DescriptorKindFilter, nameFilter: (Name) -> Boolean): List<ClassDescriptor> {
|
||||
|
||||
@@ -25,8 +25,6 @@ import java.lang.reflect.Modifier
|
||||
|
||||
public interface MemberScope : ResolutionScope {
|
||||
|
||||
val ownerDescriptor: DeclarationDescriptor
|
||||
|
||||
public override fun getContributedVariables(name: Name, location: LookupLocation): Collection<PropertyDescriptor>
|
||||
|
||||
@Deprecated("Should be removed soon")
|
||||
@@ -37,19 +35,13 @@ public interface MemberScope : ResolutionScope {
|
||||
*/
|
||||
public fun printScopeStructure(p: Printer)
|
||||
|
||||
companion object {
|
||||
public fun empty(ownerDescriptor: DeclarationDescriptor): MemberScope {
|
||||
return object : MemberScopeImpl() {
|
||||
override val ownerDescriptor = ownerDescriptor
|
||||
|
||||
override fun toString() = "Empty scope with owner: $ownerDescriptor"
|
||||
|
||||
override fun printScopeStructure(p: Printer) {
|
||||
p.println(toString())
|
||||
}
|
||||
}
|
||||
object Empty : MemberScopeImpl() {
|
||||
override fun printScopeStructure(p: Printer) {
|
||||
p.println("Empty member scope")
|
||||
}
|
||||
}
|
||||
|
||||
companion object {
|
||||
public val ALL_NAME_FILTER: (Name) -> Boolean = { true }
|
||||
}
|
||||
}
|
||||
|
||||
@@ -57,9 +57,6 @@ public class StaticScopeForKotlinClass(
|
||||
|
||||
override fun getContributedFunctions(name: Name, location: LookupLocation) = functions.filterTo(ArrayList<FunctionDescriptor>(2)) { it.getName() == name }
|
||||
|
||||
override val ownerDescriptor: DeclarationDescriptor
|
||||
get() = containingClass
|
||||
|
||||
override fun printScopeStructure(p: Printer) {
|
||||
p.println("Static scope for $containingClass")
|
||||
}
|
||||
|
||||
@@ -67,9 +67,6 @@ public class SubstitutingScope(private val workerScope: MemberScope, private val
|
||||
|
||||
override fun getPackage(name: Name) = workerScope.getPackage(name)
|
||||
|
||||
override val ownerDescriptor: DeclarationDescriptor
|
||||
get() = workerScope.ownerDescriptor
|
||||
|
||||
override fun getContributedDescriptors(kindFilter: DescriptorKindFilter,
|
||||
nameFilter: (Name) -> Boolean) = _allDescriptors
|
||||
|
||||
|
||||
@@ -191,12 +191,6 @@ public class ErrorUtils {
|
||||
return Collections.<FunctionDescriptor>singleton(createErrorFunction(this));
|
||||
}
|
||||
|
||||
@NotNull
|
||||
@Override
|
||||
public DeclarationDescriptor getOwnerDescriptor() {
|
||||
return ERROR_MODULE;
|
||||
}
|
||||
|
||||
@NotNull
|
||||
@Override
|
||||
public Collection<DeclarationDescriptor> getContributedDescriptors(
|
||||
@@ -248,12 +242,6 @@ public class ErrorUtils {
|
||||
throw new IllegalStateException();
|
||||
}
|
||||
|
||||
@NotNull
|
||||
@Override
|
||||
public DeclarationDescriptor getOwnerDescriptor() {
|
||||
return ERROR_MODULE;
|
||||
}
|
||||
|
||||
@NotNull
|
||||
@Override
|
||||
public Collection<DeclarationDescriptor> getContributedDescriptors(
|
||||
|
||||
+2
-5
@@ -116,9 +116,6 @@ public abstract class DeserializedMemberScope protected constructor(
|
||||
|
||||
protected abstract fun addClassDescriptors(result: MutableCollection<DeclarationDescriptor>, nameFilter: (Name) -> Boolean)
|
||||
|
||||
override val ownerDescriptor: DeclarationDescriptor
|
||||
get() = c.containingDeclaration
|
||||
|
||||
protected fun computeDescriptors(
|
||||
kindFilter: DescriptorKindFilter,
|
||||
nameFilter: (Name) -> Boolean,
|
||||
@@ -180,13 +177,13 @@ public abstract class DeserializedMemberScope protected constructor(
|
||||
p.println(javaClass.simpleName, " {")
|
||||
p.pushIndent()
|
||||
|
||||
p.println("containingDeclaration = " + ownerDescriptor)
|
||||
p.println("containingDeclaration = " + c.containingDeclaration)
|
||||
|
||||
p.popIndent()
|
||||
p.println("}")
|
||||
}
|
||||
|
||||
private fun recordLookup(name: Name, from: LookupLocation) {
|
||||
c.components.lookupTracker.record(from, ownerDescriptor, this, name)
|
||||
c.components.lookupTracker.record(from, c.containingDeclaration, this, name)
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user