Removed MemberScope.ownerDescriptor
This commit is contained in:
@@ -65,7 +65,7 @@ public class InterfaceImplBodyCodegen(
|
||||
descriptor, Name.identifier(JvmAbi.DEFAULT_IMPLS_CLASS_NAME),
|
||||
Modality.FINAL, Collections.emptyList(), SourceElement.NO_SOURCE)
|
||||
|
||||
classDescriptorImpl.initialize(MemberScope.empty(classDescriptorImpl), emptySet(), null)
|
||||
classDescriptorImpl.initialize(MemberScope.Empty, emptySet(), null)
|
||||
return classDescriptorImpl
|
||||
}
|
||||
|
||||
|
||||
@@ -161,13 +161,13 @@ public class MutableClassDescriptor extends ClassDescriptorBase implements Class
|
||||
@Override
|
||||
@NotNull
|
||||
public MemberScope getUnsubstitutedMemberScope() {
|
||||
return MemberScope.Companion.empty(this); // used for getDefaultType
|
||||
return MemberScope.Empty.INSTANCE; // used for getDefaultType
|
||||
}
|
||||
|
||||
@NotNull
|
||||
@Override
|
||||
public MemberScope getStaticScope() {
|
||||
return MemberScope.Companion.empty(this);
|
||||
return MemberScope.Empty.INSTANCE;
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
+1
-1
@@ -101,7 +101,7 @@ class CodegenAnnotatingVisitor extends KtVisitorVoid {
|
||||
supertypes,
|
||||
KotlinSourceElementKt.toSourceElement(element)
|
||||
);
|
||||
classDescriptor.initialize(MemberScope.Companion.empty(classDescriptor), Collections.<ConstructorDescriptor>emptySet(), null);
|
||||
classDescriptor.initialize(MemberScope.Empty.INSTANCE, Collections.<ConstructorDescriptor>emptySet(), null);
|
||||
|
||||
bindingTrace.record(CLASS_FOR_CALLABLE, callableDescriptor, classDescriptor);
|
||||
return classDescriptor;
|
||||
|
||||
@@ -212,7 +212,7 @@ public class CodegenBinding {
|
||||
new ClassDescriptorImpl(descriptor, Name.special("<script-" + simpleName + ">"), Modality.FINAL,
|
||||
Collections.singleton(DescriptorUtilsKt.getBuiltIns(descriptor).getAnyType()),
|
||||
KotlinSourceElementKt.toSourceElement(script));
|
||||
classDescriptor.initialize(MemberScope.Companion.empty(classDescriptor), Collections.<ConstructorDescriptor>emptySet(), null);
|
||||
classDescriptor.initialize(MemberScope.Empty.INSTANCE, Collections.<ConstructorDescriptor>emptySet(), null);
|
||||
|
||||
recordClosure(trace, classDescriptor, null, asmType, fileClassesManager);
|
||||
|
||||
|
||||
+6
-6
@@ -99,7 +99,7 @@ public class IncrementalPackageFragmentProvider(
|
||||
|
||||
val memberScope: NotNullLazyValue<MemberScope> = storageManager.createLazyValue {
|
||||
if (fqName !in fqNamesToLoad) {
|
||||
MemberScope.empty(this)
|
||||
MemberScope.Empty
|
||||
}
|
||||
else {
|
||||
val moduleMapping = incrementalCache.getModuleMappingData()?.let { ModuleMapping.create(it) }
|
||||
@@ -128,10 +128,10 @@ public class IncrementalPackageFragmentProvider(
|
||||
}
|
||||
|
||||
if (scopes.isEmpty()) {
|
||||
MemberScope.empty(this)
|
||||
MemberScope.Empty
|
||||
}
|
||||
else {
|
||||
ChainedScope(this, "Member scope for incremental compilation: union of package parts data", *scopes.toTypedArray())
|
||||
ChainedScope("Member scope for incremental compilation: union of package parts data", *scopes.toTypedArray())
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -151,11 +151,11 @@ public class IncrementalPackageFragmentProvider(
|
||||
val memberScope = storageManager.createLazyValue {
|
||||
val partsData = partsNames.map { incrementalCache.getPackagePartData(it) }.filterNotNull()
|
||||
if (partsData.isEmpty())
|
||||
MemberScope.empty(this)
|
||||
MemberScope.Empty
|
||||
else {
|
||||
val scopes = partsData.map { IncrementalPackageScope(JvmProtoBufUtil.readPackageDataFrom(it.data, it.strings)) }
|
||||
ChainedScope(this,
|
||||
"Member scope for incremental compilation: union of multifile class parts data for $multifileClassFqName",
|
||||
ChainedScope(
|
||||
"Member scope for incremental compilation: union of multifile class parts data for $multifileClassFqName",
|
||||
*scopes.toTypedArray<MemberScope>())
|
||||
}
|
||||
}
|
||||
|
||||
+1
-1
@@ -67,7 +67,7 @@ class PropagationHeuristics {
|
||||
arrayTypeFromSuper.getConstructor(),
|
||||
arrayTypeFromSuper.isMarkedNullable(),
|
||||
Arrays.asList(new TypeProjectionImpl(Variance.OUT_VARIANCE, elementTypeInSuper)),
|
||||
MemberScope.Companion.empty(elementType.getMemberScope().getOwnerDescriptor()));
|
||||
MemberScope.Empty.INSTANCE);
|
||||
|
||||
data.reportError("Return type is not a subtype of overridden method. " +
|
||||
"To fix it, add annotation with Kotlin signature to super method with type "
|
||||
|
||||
+1
-4
@@ -22,17 +22,14 @@ import org.jetbrains.kotlin.name.FqName;
|
||||
import org.jetbrains.kotlin.resolve.scopes.*;
|
||||
|
||||
public class MutablePackageFragmentDescriptor extends PackageFragmentDescriptorImpl {
|
||||
private final MemberScope scope;
|
||||
|
||||
public MutablePackageFragmentDescriptor(@NotNull ModuleDescriptor module, @NotNull FqName fqName) {
|
||||
super(module, fqName);
|
||||
|
||||
scope = MemberScope.Companion.empty(module);
|
||||
}
|
||||
|
||||
@NotNull
|
||||
@Override
|
||||
public MemberScope getMemberScope() {
|
||||
return scope;
|
||||
return MemberScope.Empty.INSTANCE;
|
||||
}
|
||||
}
|
||||
|
||||
+2
-2
@@ -165,7 +165,7 @@ public class ConstraintSystemImpl : ConstraintSystem {
|
||||
|
||||
val TypeParameterDescriptor.correspondingType: KotlinType
|
||||
get() = cachedTypeForVariable.getOrPut(this) {
|
||||
KotlinTypeImpl.create(Annotations.EMPTY, this.getTypeConstructor(), false, listOf(), MemberScope.empty(this))
|
||||
KotlinTypeImpl.create(Annotations.EMPTY, this.getTypeConstructor(), false, listOf(), MemberScope.Empty)
|
||||
}
|
||||
|
||||
fun KotlinType.isProper() = !TypeUtils.containsSpecialType(this) {
|
||||
@@ -573,7 +573,7 @@ public fun createTypeSubstitutor(conversion: (TypeParameterDescriptor) -> TypePa
|
||||
if (descriptor !is TypeParameterDescriptor) return null
|
||||
val typeParameterDescriptor = conversion(descriptor) ?: return null
|
||||
|
||||
val type = KotlinTypeImpl.create(Annotations.EMPTY, typeParameterDescriptor.getTypeConstructor(), false, listOf(), MemberScope.empty(typeParameterDescriptor))
|
||||
val type = KotlinTypeImpl.create(Annotations.EMPTY, typeParameterDescriptor.getTypeConstructor(), false, listOf(), MemberScope.Empty)
|
||||
return TypeProjectionImpl(type)
|
||||
}
|
||||
})
|
||||
|
||||
@@ -45,8 +45,6 @@ class DynamicCallableDescriptors(private val builtIns: KotlinBuiltIns) {
|
||||
val dynamicType = createDynamicType(builtIns)
|
||||
|
||||
fun createDynamicDescriptorScope(call: Call, owner: DeclarationDescriptor) = object : MemberScopeImpl() {
|
||||
override val ownerDescriptor: DeclarationDescriptor get() = owner
|
||||
|
||||
override fun printScopeStructure(p: Printer) {
|
||||
p.println(javaClass.getSimpleName(), ": dynamic candidates for " + call)
|
||||
}
|
||||
|
||||
+1
-3
@@ -59,8 +59,6 @@ protected constructor(
|
||||
}.toReadOnlyList()
|
||||
}
|
||||
|
||||
override val ownerDescriptor: DeclarationDescriptor get() = thisDescriptor
|
||||
|
||||
override fun getContributedClassifier(name: Name, location: LookupLocation): ClassDescriptor? {
|
||||
recordLookup(name, location)
|
||||
return classDescriptors(name).firstOrNull()
|
||||
@@ -186,6 +184,6 @@ protected constructor(
|
||||
}
|
||||
|
||||
private fun recordLookup(name: Name, from: LookupLocation) {
|
||||
c.lookupTracker.record(from, ownerDescriptor, this, name)
|
||||
c.lookupTracker.record(from, thisDescriptor, this, name)
|
||||
}
|
||||
}
|
||||
|
||||
@@ -23,9 +23,6 @@ import org.jetbrains.kotlin.utils.Printer
|
||||
|
||||
public class FilteringScope(private val workerScope: MemberScope, private val predicate: (DeclarationDescriptor) -> Boolean) : MemberScope {
|
||||
|
||||
override val ownerDescriptor: DeclarationDescriptor
|
||||
get() = workerScope.ownerDescriptor
|
||||
|
||||
override fun getContributedFunctions(name: Name, location: LookupLocation) = workerScope.getContributedFunctions(name, location).filter(predicate)
|
||||
|
||||
private fun <D : DeclarationDescriptor> filterDescriptor(descriptor: D?): D?
|
||||
|
||||
@@ -104,7 +104,7 @@ class ClassifierQualifier(
|
||||
|
||||
override val scope: MemberScope get() {
|
||||
if (classifier !is ClassDescriptor) {
|
||||
return MemberScope.empty(classifier)
|
||||
return MemberScope.Empty
|
||||
}
|
||||
|
||||
val scopes = ArrayList<MemberScope>(3)
|
||||
@@ -120,12 +120,12 @@ class ClassifierQualifier(
|
||||
scopes.add(classifier.unsubstitutedInnerClassesScope)
|
||||
}
|
||||
|
||||
return ChainedScope(descriptor, "Member scope for $name as class or object", *scopes.toTypedArray())
|
||||
return ChainedScope("Member scope for $name as class or object", *scopes.toTypedArray())
|
||||
}
|
||||
|
||||
override fun getNestedClassesAndPackageMembersScope(): MemberScope {
|
||||
if (classifier !is ClassDescriptor) {
|
||||
return MemberScope.empty(classifier)
|
||||
return MemberScope.Empty
|
||||
}
|
||||
|
||||
val scopes = ArrayList<MemberScope>(2)
|
||||
@@ -136,7 +136,7 @@ class ClassifierQualifier(
|
||||
scopes.add(JetScopeUtils.getStaticNestedClassesScope(classifier))
|
||||
}
|
||||
|
||||
return ChainedScope(descriptor, "Static scope for $name as class or object", *scopes.toTypedArray())
|
||||
return ChainedScope("Static scope for $name as class or object", *scopes.toTypedArray())
|
||||
}
|
||||
|
||||
override fun toString() = "Classifier{$classifier}"
|
||||
|
||||
@@ -136,7 +136,7 @@ public class TypeIntersector {
|
||||
constructor,
|
||||
allNullable,
|
||||
Collections.<TypeProjection>emptyList(),
|
||||
new IntersectionScope(constructor, scopes)
|
||||
new ChainedScope("member scope for intersection type " + constructor, scopes)
|
||||
);
|
||||
}
|
||||
|
||||
@@ -153,19 +153,6 @@ public class TypeIntersector {
|
||||
return upperBoundsAsType != null ? upperBoundsAsType : getBuiltIns(descriptor).getNothingType();
|
||||
}
|
||||
|
||||
// TODO: check intersectability, don't use a chained scope
|
||||
private static class IntersectionScope extends ChainedScope {
|
||||
public IntersectionScope(@NotNull TypeConstructor constructor, @NotNull MemberScope[] scopes) {
|
||||
super(null, "member scope for intersection type " + constructor, scopes);
|
||||
}
|
||||
|
||||
@NotNull
|
||||
@Override
|
||||
public DeclarationDescriptor getOwnerDescriptor() {
|
||||
throw new UnsupportedOperationException("Should not call getContainingDeclaration on intersection scope " + this);
|
||||
}
|
||||
}
|
||||
|
||||
private static class TypeUnifier {
|
||||
private static class TypeParameterUsage {
|
||||
private final TypeParameterDescriptor typeParameterDescriptor;
|
||||
|
||||
+2
-5
@@ -191,7 +191,7 @@ public abstract class AbstractJvmRuntimeDescriptorLoaderTest : TestCaseWithTmpdi
|
||||
private val scope: MemberScope
|
||||
|
||||
init {
|
||||
scope = ChainedScope(this, "synthetic package view for test", ScopeWithClassifiers(classes, this), *packageScopes.toTypedArray())
|
||||
scope = ChainedScope("synthetic package view for test", ScopeWithClassifiers(classes), *packageScopes.toTypedArray())
|
||||
}
|
||||
|
||||
override val fqName: FqName
|
||||
@@ -211,10 +211,7 @@ public abstract class AbstractJvmRuntimeDescriptorLoaderTest : TestCaseWithTmpdi
|
||||
get() = throw UnsupportedOperationException()
|
||||
}
|
||||
|
||||
private class ScopeWithClassifiers(
|
||||
classifiers: List<ClassifierDescriptor>,
|
||||
override val ownerDescriptor: DeclarationDescriptor
|
||||
) : MemberScopeImpl() {
|
||||
private class ScopeWithClassifiers(classifiers: List<ClassifierDescriptor>) : MemberScopeImpl() {
|
||||
private val classifierMap = HashMap<Name, ClassifierDescriptor>()
|
||||
val redeclarationHandler = RedeclarationHandler.THROW_EXCEPTION
|
||||
|
||||
|
||||
+1
-1
@@ -66,7 +66,7 @@ public class ConstraintSystemTestData(
|
||||
val number = matcher.group(1)!!
|
||||
return KotlinTypeImpl.create(
|
||||
Annotations.EMPTY, IntegerValueTypeConstructor(number.toLong(), functionFoo.builtIns), false, listOf(),
|
||||
MemberScope.empty(functionFoo)
|
||||
MemberScope.Empty
|
||||
)
|
||||
}
|
||||
return typeResolver.resolveType(
|
||||
|
||||
+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)
|
||||
}
|
||||
}
|
||||
|
||||
+2
-2
@@ -40,7 +40,7 @@ private class PackageFragmentWithMissingDependencies(override val fqName: FqName
|
||||
}
|
||||
}
|
||||
|
||||
private class ScopeWithMissingDependencies(val fqName: FqName, override val ownerDescriptor: DeclarationDescriptor) : MemberScopeImpl() {
|
||||
private class ScopeWithMissingDependencies(val fqName: FqName, val ownerDescriptor: DeclarationDescriptor) : MemberScopeImpl() {
|
||||
|
||||
override fun printScopeStructure(p: Printer) {
|
||||
p.println("Special scope for decompiler, containing class with any name")
|
||||
@@ -71,7 +71,7 @@ private class MissingDependencyErrorClassDescriptor(
|
||||
val emptyConstructor = ConstructorDescriptorImpl.create(this, Annotations.EMPTY, true, SourceElement.NO_SOURCE)
|
||||
emptyConstructor.initialize(listOf(), listOf(), Visibilities.DEFAULT_VISIBILITY)
|
||||
emptyConstructor.setReturnType(createErrorType("<ERROR RETURN TYPE>"))
|
||||
initialize(MemberScope.empty(this), setOf(emptyConstructor), emptyConstructor)
|
||||
initialize(MemberScope.Empty, setOf(emptyConstructor), emptyConstructor)
|
||||
}
|
||||
|
||||
override fun substitute(substitutor: TypeSubstitutor) = this
|
||||
|
||||
Reference in New Issue
Block a user