Drop TypeConstructor.getAnnotations(), uninherit TypeConstructor from Annotated

The method was unused on TypeConstructor instances, and almost all
implementations returned EMPTY anyway
This commit is contained in:
Alexander Udalov
2016-10-12 15:04:19 +03:00
parent 6b6ddf5f75
commit cdf6567375
20 changed files with 10 additions and 82 deletions
@@ -20,8 +20,8 @@ import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.Nullable; import org.jetbrains.annotations.Nullable;
import org.jetbrains.kotlin.descriptors.*; import org.jetbrains.kotlin.descriptors.*;
import org.jetbrains.kotlin.descriptors.annotations.Annotations; import org.jetbrains.kotlin.descriptors.annotations.Annotations;
import org.jetbrains.kotlin.descriptors.impl.ClassDescriptorBase;
import org.jetbrains.kotlin.descriptors.impl.ClassConstructorDescriptorImpl; import org.jetbrains.kotlin.descriptors.impl.ClassConstructorDescriptorImpl;
import org.jetbrains.kotlin.descriptors.impl.ClassDescriptorBase;
import org.jetbrains.kotlin.descriptors.impl.DeclarationDescriptorImpl; import org.jetbrains.kotlin.descriptors.impl.DeclarationDescriptorImpl;
import org.jetbrains.kotlin.name.Name; import org.jetbrains.kotlin.name.Name;
import org.jetbrains.kotlin.resolve.scopes.MemberScope; import org.jetbrains.kotlin.resolve.scopes.MemberScope;
@@ -151,9 +151,7 @@ public class MutableClassDescriptor extends ClassDescriptorBase implements Class
public void createTypeConstructor() { public void createTypeConstructor() {
assert typeConstructor == null : typeConstructor; assert typeConstructor == null : typeConstructor;
this.typeConstructor = new ClassTypeConstructorImpl( this.typeConstructor = new ClassTypeConstructorImpl(this, ModalityKt.isFinalClass(this), typeParameters, supertypes);
this, Annotations.Companion.getEMPTY(), ModalityKt.isFinalClass(this), typeParameters, supertypes
);
for (FunctionDescriptor functionDescriptor : getConstructors()) { for (FunctionDescriptor functionDescriptor : getConstructors()) {
((ClassConstructorDescriptorImpl) functionDescriptor).setReturnType(getDefaultType()); ((ClassConstructorDescriptorImpl) functionDescriptor).setReturnType(getDefaultType());
} }
@@ -656,12 +656,6 @@ public class LazyClassDescriptor extends ClassDescriptorBase implements ClassDes
return LazyClassDescriptor.this; return LazyClassDescriptor.this;
} }
@NotNull
@Override
public Annotations getAnnotations() {
return Annotations.Companion.getEMPTY(); // TODO
}
@Override @Override
public String toString() { public String toString() {
return LazyClassDescriptor.this.getName().toString(); return LazyClassDescriptor.this.getName().toString();
@@ -51,7 +51,7 @@ open class KnownClassDescriptor(
fun initialize(declaredTypeParameters: List<TypeParameterDescriptor>, supertypes: List<KotlinType>) { fun initialize(declaredTypeParameters: List<TypeParameterDescriptor>, supertypes: List<KotlinType>) {
this.declaredTypeParameters = declaredTypeParameters this.declaredTypeParameters = declaredTypeParameters
this.supertypes = supertypes this.supertypes = supertypes
this.typeConstructor = ClassTypeConstructorImpl(this, annotations, true, declaredTypeParameters, supertypes) this.typeConstructor = ClassTypeConstructorImpl(this, true, declaredTypeParameters, supertypes)
this.defaultType = TypeUtils.makeUnsubstitutedType(this, unsubstitutedMemberScope) this.defaultType = TypeUtils.makeUnsubstitutedType(this, unsubstitutedMemberScope)
} }
@@ -216,8 +216,6 @@ class LazyJavaClassDescriptor(
override val supertypeLoopChecker: SupertypeLoopChecker override val supertypeLoopChecker: SupertypeLoopChecker
get() = c.components.supertypeLoopChecker get() = c.components.supertypeLoopChecker
override val annotations: Annotations get() = Annotations.EMPTY
override fun isFinal(): Boolean = isFinalClass override fun isFinal(): Boolean = isFinalClass
override fun isDenotable() = true override fun isDenotable() = true
@@ -143,7 +143,6 @@ class FunctionClassDescriptor(
override fun getDeclarationDescriptor() = this@FunctionClassDescriptor override fun getDeclarationDescriptor() = this@FunctionClassDescriptor
override fun isDenotable() = true override fun isDenotable() = true
override fun isFinal() = false override fun isFinal() = false
override val annotations: Annotations get() = Annotations.EMPTY
override fun toString() = declarationDescriptor.toString() override fun toString() = declarationDescriptor.toString()
@@ -88,10 +88,6 @@ abstract class AbstractTypeAliasDescriptor(
override fun getBuiltIns(): KotlinBuiltIns = override fun getBuiltIns(): KotlinBuiltIns =
declarationDescriptor.builtIns declarationDescriptor.builtIns
override val annotations: Annotations
get() = declarationDescriptor.annotations
override fun toString(): String = "[typealias ${declarationDescriptor.name.asString()}]" override fun toString(): String = "[typealias ${declarationDescriptor.name.asString()}]"
} }
} }
@@ -183,12 +183,6 @@ public abstract class AbstractTypeParameterDescriptor extends DeclarationDescrip
return AbstractTypeParameterDescriptor.this; return AbstractTypeParameterDescriptor.this;
} }
@NotNull
@Override
public Annotations getAnnotations() {
return AbstractTypeParameterDescriptor.this.getAnnotations();
}
@NotNull @NotNull
@Override @Override
public KotlinBuiltIns getBuiltIns() { public KotlinBuiltIns getBuiltIns() {
@@ -53,9 +53,7 @@ public class ClassDescriptorImpl extends ClassDescriptorBase {
this.modality = modality; this.modality = modality;
this.kind = kind; this.kind = kind;
this.typeConstructor = new ClassTypeConstructorImpl( this.typeConstructor = new ClassTypeConstructorImpl(this, false, Collections.<TypeParameterDescriptor>emptyList(), supertypes);
this, Annotations.Companion.getEMPTY(), false, Collections.<TypeParameterDescriptor>emptyList(), supertypes
);
} }
public final void initialize( public final void initialize(
@@ -80,7 +80,7 @@ public class EnumEntrySyntheticClassDescriptor extends ClassDescriptorBase {
this.annotations = annotations; this.annotations = annotations;
this.typeConstructor = new ClassTypeConstructorImpl( this.typeConstructor = new ClassTypeConstructorImpl(
this, getAnnotations(), true, Collections.<TypeParameterDescriptor>emptyList(), Collections.singleton(supertype) this, true, Collections.<TypeParameterDescriptor>emptyList(), Collections.singleton(supertype)
); );
this.scope = new EnumEntryScope(storageManager); this.scope = new EnumEntryScope(storageManager);
@@ -84,9 +84,7 @@ public class LazySubstitutingClassDescriptor implements ClassDescriptor {
supertypes.add(substitutor.substitute(supertype, Variance.INVARIANT)); supertypes.add(substitutor.substitute(supertype, Variance.INVARIANT));
} }
typeConstructor = new ClassTypeConstructorImpl( typeConstructor = new ClassTypeConstructorImpl(this, originalTypeConstructor.isFinal(), typeConstructorParameters, supertypes);
this, originalTypeConstructor.getAnnotations(), originalTypeConstructor.isFinal(), typeConstructorParameters, supertypes
);
} }
return typeConstructor; return typeConstructor;
@@ -54,8 +54,6 @@ class CapturedTypeConstructor(
override fun getDeclarationDescriptor() = null override fun getDeclarationDescriptor() = null
override val annotations: Annotations get() = Annotations.EMPTY
override fun toString() = "CapturedTypeConstructor($typeProjection)" override fun toString() = "CapturedTypeConstructor($typeProjection)"
override fun getBuiltIns(): KotlinBuiltIns = typeProjection.type.constructor.builtIns override fun getBuiltIns(): KotlinBuiltIns = typeProjection.type.constructor.builtIns
@@ -18,7 +18,6 @@ package org.jetbrains.kotlin.resolve.constants
import org.jetbrains.kotlin.builtins.KotlinBuiltIns import org.jetbrains.kotlin.builtins.KotlinBuiltIns
import org.jetbrains.kotlin.descriptors.TypeParameterDescriptor import org.jetbrains.kotlin.descriptors.TypeParameterDescriptor
import org.jetbrains.kotlin.descriptors.annotations.Annotations
import org.jetbrains.kotlin.types.KotlinType import org.jetbrains.kotlin.types.KotlinType
import org.jetbrains.kotlin.types.TypeConstructor import org.jetbrains.kotlin.types.TypeConstructor
import java.util.* import java.util.*
@@ -55,13 +54,11 @@ class IntegerValueTypeConstructor(
override fun getDeclarationDescriptor() = null override fun getDeclarationDescriptor() = null
override val annotations: Annotations get() = Annotations.EMPTY
fun getValue(): Long = value fun getValue(): Long = value
override fun getBuiltIns(): KotlinBuiltIns { override fun getBuiltIns(): KotlinBuiltIns {
return builtIns return builtIns
} }
override fun toString() = "IntegerValueType(" + value + ")" override fun toString() = "IntegerValueType($value)"
} }
@@ -20,7 +20,6 @@ import org.jetbrains.annotations.NotNull;
import org.jetbrains.kotlin.descriptors.ClassDescriptor; import org.jetbrains.kotlin.descriptors.ClassDescriptor;
import org.jetbrains.kotlin.descriptors.SupertypeLoopChecker; import org.jetbrains.kotlin.descriptors.SupertypeLoopChecker;
import org.jetbrains.kotlin.descriptors.TypeParameterDescriptor; import org.jetbrains.kotlin.descriptors.TypeParameterDescriptor;
import org.jetbrains.kotlin.descriptors.annotations.Annotations;
import org.jetbrains.kotlin.resolve.DescriptorUtils; import org.jetbrains.kotlin.resolve.DescriptorUtils;
import org.jetbrains.kotlin.storage.LockBasedStorageManager; import org.jetbrains.kotlin.storage.LockBasedStorageManager;
@@ -31,21 +30,18 @@ import java.util.List;
public class ClassTypeConstructorImpl extends AbstractClassTypeConstructor implements TypeConstructor { public class ClassTypeConstructorImpl extends AbstractClassTypeConstructor implements TypeConstructor {
private final ClassDescriptor classDescriptor; private final ClassDescriptor classDescriptor;
private final Annotations annotations;
private final List<TypeParameterDescriptor> parameters; private final List<TypeParameterDescriptor> parameters;
private final Collection<KotlinType> supertypes; private final Collection<KotlinType> supertypes;
private final boolean isFinal; private final boolean isFinal;
public ClassTypeConstructorImpl( public ClassTypeConstructorImpl(
@NotNull ClassDescriptor classDescriptor, @NotNull ClassDescriptor classDescriptor,
@NotNull Annotations annotations,
boolean isFinal, boolean isFinal,
@NotNull List<? extends TypeParameterDescriptor> parameters, @NotNull List<? extends TypeParameterDescriptor> parameters,
@NotNull Collection<KotlinType> supertypes @NotNull Collection<KotlinType> supertypes
) { ) {
super(LockBasedStorageManager.NO_LOCKS); super(LockBasedStorageManager.NO_LOCKS);
this.classDescriptor = classDescriptor; this.classDescriptor = classDescriptor;
this.annotations = annotations;
this.isFinal = isFinal; this.isFinal = isFinal;
this.parameters = Collections.unmodifiableList(new ArrayList<TypeParameterDescriptor>(parameters)); this.parameters = Collections.unmodifiableList(new ArrayList<TypeParameterDescriptor>(parameters));
this.supertypes = Collections.unmodifiableCollection(supertypes); this.supertypes = Collections.unmodifiableCollection(supertypes);
@@ -89,10 +85,4 @@ public class ClassTypeConstructorImpl extends AbstractClassTypeConstructor imple
protected SupertypeLoopChecker getSupertypeLoopChecker() { protected SupertypeLoopChecker getSupertypeLoopChecker() {
return SupertypeLoopChecker.EMPTY.INSTANCE; return SupertypeLoopChecker.EMPTY.INSTANCE;
} }
@NotNull
@Override
public Annotations getAnnotations() {
return annotations;
}
} }
@@ -460,12 +460,6 @@ public class ErrorUtils {
return DefaultBuiltIns.getInstance(); return DefaultBuiltIns.getInstance();
} }
@NotNull
@Override
public Annotations getAnnotations() {
return Annotations.Companion.getEMPTY();
}
@Override @Override
public String toString() { public String toString() {
return debugName; return debugName;
@@ -631,12 +625,6 @@ public class ErrorUtils {
return errorTypeConstructor.getDeclarationDescriptor(); return errorTypeConstructor.getDeclarationDescriptor();
} }
@NotNull
@Override
public Annotations getAnnotations() {
return errorTypeConstructor.getAnnotations();
}
@NotNull @NotNull
@Override @Override
public KotlinBuiltIns getBuiltIns() { public KotlinBuiltIns getBuiltIns() {
@@ -19,7 +19,6 @@ package org.jetbrains.kotlin.types
import org.jetbrains.kotlin.builtins.KotlinBuiltIns import org.jetbrains.kotlin.builtins.KotlinBuiltIns
import org.jetbrains.kotlin.descriptors.ClassifierDescriptor import org.jetbrains.kotlin.descriptors.ClassifierDescriptor
import org.jetbrains.kotlin.descriptors.TypeParameterDescriptor import org.jetbrains.kotlin.descriptors.TypeParameterDescriptor
import org.jetbrains.kotlin.descriptors.annotations.Annotations
class FunctionPlaceholders(private val builtIns: KotlinBuiltIns) { class FunctionPlaceholders(private val builtIns: KotlinBuiltIns) {
fun createFunctionPlaceholderType( fun createFunctionPlaceholderType(
@@ -65,10 +64,6 @@ class FunctionPlaceholderTypeConstructor(
return errorTypeConstructor.declarationDescriptor return errorTypeConstructor.declarationDescriptor
} }
override val annotations: Annotations get(): Annotations {
return errorTypeConstructor.annotations
}
override fun toString(): String { override fun toString(): String {
return errorTypeConstructor.toString() return errorTypeConstructor.toString()
} }
@@ -20,8 +20,6 @@ import org.jetbrains.annotations.NotNull;
import org.jetbrains.kotlin.builtins.KotlinBuiltIns; import org.jetbrains.kotlin.builtins.KotlinBuiltIns;
import org.jetbrains.kotlin.descriptors.ClassifierDescriptor; import org.jetbrains.kotlin.descriptors.ClassifierDescriptor;
import org.jetbrains.kotlin.descriptors.TypeParameterDescriptor; import org.jetbrains.kotlin.descriptors.TypeParameterDescriptor;
import org.jetbrains.kotlin.descriptors.annotations.AnnotatedImpl;
import org.jetbrains.kotlin.descriptors.annotations.Annotations;
import org.jetbrains.kotlin.resolve.scopes.MemberScope; import org.jetbrains.kotlin.resolve.scopes.MemberScope;
import org.jetbrains.kotlin.resolve.scopes.TypeIntersectionScope; import org.jetbrains.kotlin.resolve.scopes.TypeIntersectionScope;
@@ -110,10 +108,4 @@ public class IntersectionTypeConstructor implements TypeConstructor {
public int hashCode() { public int hashCode() {
return hashCode; return hashCode;
} }
@NotNull
@Override
public Annotations getAnnotations() {
return Annotations.Companion.getEMPTY();
}
} }
@@ -22,12 +22,11 @@ import org.jetbrains.annotations.ReadOnly;
import org.jetbrains.kotlin.builtins.KotlinBuiltIns; import org.jetbrains.kotlin.builtins.KotlinBuiltIns;
import org.jetbrains.kotlin.descriptors.ClassifierDescriptor; import org.jetbrains.kotlin.descriptors.ClassifierDescriptor;
import org.jetbrains.kotlin.descriptors.TypeParameterDescriptor; import org.jetbrains.kotlin.descriptors.TypeParameterDescriptor;
import org.jetbrains.kotlin.descriptors.annotations.Annotated;
import java.util.Collection; import java.util.Collection;
import java.util.List; import java.util.List;
public interface TypeConstructor extends Annotated { public interface TypeConstructor {
/** /**
* It may differ from ClassDescriptor.declaredParameters if the class is inner, in such case * It may differ from ClassDescriptor.declaredParameters if the class is inner, in such case
* it also contains additional parameters from outer declarations. * it also contains additional parameters from outer declarations.
@@ -116,8 +116,6 @@ class NewCapturedTypeConstructor(val projection: TypeProjection, private var sup
override fun isDenotable() = false override fun isDenotable() = false
override fun getDeclarationDescriptor(): ClassifierDescriptor? = null override fun getDeclarationDescriptor(): ClassifierDescriptor? = null
override fun getBuiltIns(): KotlinBuiltIns = projection.type.builtIns override fun getBuiltIns(): KotlinBuiltIns = projection.type.builtIns
override val annotations: Annotations get() = Annotations.EMPTY
override fun toString() = "CapturedType($projection)" override fun toString() = "CapturedType($projection)"
} }
@@ -89,9 +89,7 @@ class NotFoundClasses(private val storageManager: StorageManager, private val mo
) : ClassDescriptorBase(storageManager, container, name, SourceElement.NO_SOURCE) { ) : ClassDescriptorBase(storageManager, container, name, SourceElement.NO_SOURCE) {
private val typeParameters = createTypeParameters(this, numberOfDeclaredTypeParameters) private val typeParameters = createTypeParameters(this, numberOfDeclaredTypeParameters)
private val typeConstructor = ClassTypeConstructorImpl( private val typeConstructor = ClassTypeConstructorImpl(this, /* isFinal = */ true, typeParameters, setOf(module.builtIns.anyType))
this, Annotations.EMPTY, /* isFinal = */ true, typeParameters, setOf(module.builtIns.anyType)
)
override fun getKind() = ClassKind.CLASS override fun getKind() = ClassKind.CLASS
override fun getModality() = Modality.FINAL override fun getModality() = Modality.FINAL
@@ -176,8 +176,6 @@ class DeserializedClassDescriptor(
override fun getDeclarationDescriptor() = this@DeserializedClassDescriptor override fun getDeclarationDescriptor() = this@DeserializedClassDescriptor
override val annotations: Annotations get() = Annotations.EMPTY // TODO
override fun toString() = name.toString() override fun toString() = name.toString()
override val supertypeLoopChecker: SupertypeLoopChecker override val supertypeLoopChecker: SupertypeLoopChecker