Wire StorageManager into a ClassTypeConstructorImpl and ClassDescriptorImpl

This commit is contained in:
Dmitry Savvinov
2018-04-11 18:55:01 +03:00
parent 1477e67076
commit 934c56a4da
19 changed files with 67 additions and 37 deletions
@@ -36,7 +36,7 @@ class JvmBuiltInClassDescriptorFactory(
ClassDescriptorImpl(
computeContainingDeclaration(moduleDescriptor),
CLONEABLE_NAME, Modality.ABSTRACT, ClassKind.INTERFACE, listOf(moduleDescriptor.builtIns.anyType),
SourceElement.NO_SOURCE, /* isExternal = */ false
SourceElement.NO_SOURCE, /* isExternal = */ false, storageManager
).apply {
initialize(CloneableClassScope(storageManager, this), emptySet(), null)
}
@@ -91,7 +91,7 @@ open class JvmBuiltInsSettings(
val mockSerializableClass = ClassDescriptorImpl(
mockJavaIoPackageFragment, Name.identifier("Serializable"), Modality.ABSTRACT, ClassKind.INTERFACE, superTypes,
SourceElement.NO_SOURCE, /* isExternal = */ false
SourceElement.NO_SOURCE, /* isExternal = */ false, this
)
mockSerializableClass.initialize(MemberScope.Empty, emptySet(), null)
@@ -17,6 +17,7 @@ import org.jetbrains.kotlin.name.FqName
import org.jetbrains.kotlin.name.Name
import org.jetbrains.kotlin.resolve.DescriptorUtils
import org.jetbrains.kotlin.resolve.descriptorUtil.fqNameSafe
import org.jetbrains.kotlin.storage.LockBasedStorageManager
import org.jetbrains.kotlin.types.*
import org.jetbrains.kotlin.types.typeUtil.asTypeProjection
import org.jetbrains.kotlin.types.typeUtil.builtIns
@@ -25,7 +26,7 @@ val FAKE_CONTINUATION_CLASS_DESCRIPTOR_EXPERIMENTAL =
MutableClassDescriptor(
EmptyPackageFragmentDescriptor(ErrorUtils.getErrorModule(), DescriptorUtils.COROUTINES_PACKAGE_FQ_NAME_EXPERIMENTAL),
ClassKind.INTERFACE, /* isInner = */ false, /* isExternal = */ false,
DescriptorUtils.CONTINUATION_INTERFACE_FQ_NAME_EXPERIMENTAL.shortName(), SourceElement.NO_SOURCE
DescriptorUtils.CONTINUATION_INTERFACE_FQ_NAME_EXPERIMENTAL.shortName(), SourceElement.NO_SOURCE, LockBasedStorageManager.NO_LOCKS
).apply {
modality = Modality.ABSTRACT
visibility = Visibilities.PUBLIC
@@ -41,7 +42,7 @@ val FAKE_CONTINUATION_CLASS_DESCRIPTOR_RELEASE =
MutableClassDescriptor(
EmptyPackageFragmentDescriptor(ErrorUtils.getErrorModule(), DescriptorUtils.COROUTINES_PACKAGE_FQ_NAME_RELEASE),
ClassKind.INTERFACE, /* isInner = */ false, /* isExternal = */ false,
DescriptorUtils.CONTINUATION_INTERFACE_FQ_NAME_RELEASE.shortName(), SourceElement.NO_SOURCE
DescriptorUtils.CONTINUATION_INTERFACE_FQ_NAME_RELEASE.shortName(), SourceElement.NO_SOURCE, LockBasedStorageManager.NO_LOCKS
).apply {
modality = Modality.ABSTRACT
visibility = Visibilities.PUBLIC
@@ -56,7 +56,7 @@ class NotFoundClasses(private val storageManager: StorageManager, private val mo
)
}
private val typeConstructor = ClassTypeConstructorImpl(this, typeParameters, setOf(module.builtIns.anyType))
private val typeConstructor = ClassTypeConstructorImpl(this, typeParameters, setOf(module.builtIns.anyType), storageManager)
override fun getKind() = ClassKind.CLASS
override fun getModality() = Modality.FINAL
@@ -12,6 +12,7 @@ import org.jetbrains.kotlin.descriptors.annotations.Annotations;
import org.jetbrains.kotlin.name.Name;
import org.jetbrains.kotlin.resolve.scopes.MemberScope;
import org.jetbrains.kotlin.storage.LockBasedStorageManager;
import org.jetbrains.kotlin.storage.StorageManager;
import org.jetbrains.kotlin.types.ClassTypeConstructorImpl;
import org.jetbrains.kotlin.types.KotlinType;
import org.jetbrains.kotlin.types.TypeConstructor;
@@ -37,14 +38,15 @@ public class ClassDescriptorImpl extends ClassDescriptorBase {
@NotNull ClassKind kind,
@NotNull Collection<KotlinType> supertypes,
@NotNull SourceElement source,
boolean isExternal
boolean isExternal,
@NotNull StorageManager storageManager
) {
super(LockBasedStorageManager.NO_LOCKS, containingDeclaration, name, source, isExternal);
super(storageManager, containingDeclaration, name, source, isExternal);
assert modality != Modality.SEALED : "Implement getSealedSubclasses() for this class: " + getClass();
this.modality = modality;
this.kind = kind;
this.typeConstructor = new ClassTypeConstructorImpl(this, Collections.<TypeParameterDescriptor>emptyList(), supertypes);
this.typeConstructor = new ClassTypeConstructorImpl(this, Collections.<TypeParameterDescriptor>emptyList(), supertypes, storageManager);
}
public final void initialize(
@@ -69,7 +69,7 @@ public class EnumEntrySyntheticClassDescriptor extends ClassDescriptorBase {
this.annotations = annotations;
this.typeConstructor = new ClassTypeConstructorImpl(
this, Collections.<TypeParameterDescriptor>emptyList(), Collections.singleton(supertype)
this, Collections.<TypeParameterDescriptor>emptyList(), Collections.singleton(supertype), storageManager
);
this.scope = new EnumEntryScope(storageManager);
@@ -14,6 +14,7 @@ import org.jetbrains.kotlin.descriptors.annotations.Annotations;
import org.jetbrains.kotlin.name.Name;
import org.jetbrains.kotlin.resolve.scopes.MemberScope;
import org.jetbrains.kotlin.resolve.scopes.SubstitutingScope;
import org.jetbrains.kotlin.storage.LockBasedStorageManager;
import org.jetbrains.kotlin.types.*;
import java.util.ArrayList;
@@ -73,7 +74,7 @@ public class LazySubstitutingClassDescriptor implements ClassDescriptor {
supertypes.add(substitutor.substitute(supertype, Variance.INVARIANT));
}
typeConstructor = new ClassTypeConstructorImpl(this, typeConstructorParameters, supertypes);
typeConstructor = new ClassTypeConstructorImpl(this, typeConstructorParameters, supertypes, LockBasedStorageManager.NO_LOCKS);
}
return typeConstructor;
@@ -11,7 +11,7 @@ import org.jetbrains.kotlin.descriptors.*;
import org.jetbrains.kotlin.descriptors.annotations.Annotations;
import org.jetbrains.kotlin.name.Name;
import org.jetbrains.kotlin.resolve.scopes.MemberScope;
import org.jetbrains.kotlin.storage.LockBasedStorageManager;
import org.jetbrains.kotlin.storage.StorageManager;
import org.jetbrains.kotlin.types.*;
import java.util.*;
@@ -25,6 +25,7 @@ public class MutableClassDescriptor extends ClassDescriptorBase {
private TypeConstructor typeConstructor;
private List<TypeParameterDescriptor> typeParameters;
private final Collection<KotlinType> supertypes = new ArrayList<KotlinType>();
private final StorageManager storageManager;
public MutableClassDescriptor(
@NotNull DeclarationDescriptor containingDeclaration,
@@ -32,9 +33,11 @@ public class MutableClassDescriptor extends ClassDescriptorBase {
boolean isInner,
boolean isExternal,
@NotNull Name name,
@NotNull SourceElement source
@NotNull SourceElement source,
@NotNull StorageManager storageManager
) {
super(LockBasedStorageManager.NO_LOCKS, containingDeclaration, name, source, isExternal);
super(storageManager, containingDeclaration, name, source, isExternal);
this.storageManager = storageManager;
assert kind != ClassKind.OBJECT : "Fix isCompanionObject()";
this.kind = kind;
@@ -151,7 +154,7 @@ public class MutableClassDescriptor extends ClassDescriptorBase {
public void createTypeConstructor() {
assert typeConstructor == null : typeConstructor;
this.typeConstructor = new ClassTypeConstructorImpl(this, typeParameters, supertypes);
this.typeConstructor = new ClassTypeConstructorImpl(this, typeParameters, supertypes, storageManager);
for (FunctionDescriptor functionDescriptor : getConstructors()) {
((ClassConstructorDescriptorImpl) functionDescriptor).setReturnType(getDefaultType());
}
@@ -22,6 +22,7 @@ import org.jetbrains.kotlin.descriptors.SupertypeLoopChecker;
import org.jetbrains.kotlin.descriptors.TypeParameterDescriptor;
import org.jetbrains.kotlin.resolve.DescriptorUtils;
import org.jetbrains.kotlin.storage.LockBasedStorageManager;
import org.jetbrains.kotlin.storage.StorageManager;
import java.util.ArrayList;
import java.util.Collection;
@@ -36,9 +37,10 @@ public class ClassTypeConstructorImpl extends AbstractClassTypeConstructor imple
public ClassTypeConstructorImpl(
@NotNull ClassDescriptor classDescriptor,
@NotNull List<? extends TypeParameterDescriptor> parameters,
@NotNull Collection<KotlinType> supertypes
@NotNull Collection<KotlinType> supertypes,
@NotNull StorageManager storageManager
) {
super(LockBasedStorageManager.NO_LOCKS);
super(storageManager);
this.classDescriptor = classDescriptor;
this.parameters = Collections.unmodifiableList(new ArrayList<TypeParameterDescriptor>(parameters));
this.supertypes = Collections.unmodifiableCollection(supertypes);
@@ -33,6 +33,7 @@ import org.jetbrains.kotlin.name.Name;
import org.jetbrains.kotlin.resolve.descriptorUtil.DescriptorUtilsKt;
import org.jetbrains.kotlin.resolve.scopes.DescriptorKindFilter;
import org.jetbrains.kotlin.resolve.scopes.MemberScope;
import org.jetbrains.kotlin.storage.LockBasedStorageManager;
import org.jetbrains.kotlin.types.error.ErrorSimpleFunctionDescriptorImpl;
import org.jetbrains.kotlin.utils.Printer;
@@ -343,7 +344,7 @@ public class ErrorUtils {
public ErrorClassDescriptor(@NotNull Name name) {
super(getErrorModule(), name,
Modality.OPEN, ClassKind.CLASS, Collections.<KotlinType>emptyList(), SourceElement.NO_SOURCE,
/* isExternal = */ false
/* isExternal = */ false, LockBasedStorageManager.NO_LOCKS
);
ClassConstructorDescriptorImpl