Removed MemberScope.ownerDescriptor

This commit is contained in:
Stanislav Erokhin
2015-11-05 02:16:36 +03:00
parent 22f78b148c
commit 55157df3eb
36 changed files with 61 additions and 155 deletions
@@ -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
@@ -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);
@@ -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>())
}
}
@@ -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 "
@@ -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;
}
}
@@ -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)
}
@@ -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;
@@ -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
@@ -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(