ClassDescriptor is now a super-interface for ClassConstructorDescriptor and TypeAliasConstructorDescriptor.
This commit is contained in:
committed by
Dmitry Petrov
parent
7d214c6e58
commit
796d11c860
+2
-5
@@ -20,10 +20,7 @@ import kotlin.Unit;
|
||||
import kotlin.jvm.functions.Function1;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
import org.jetbrains.kotlin.descriptors.CallableMemberDescriptor;
|
||||
import org.jetbrains.kotlin.descriptors.ClassDescriptor;
|
||||
import org.jetbrains.kotlin.descriptors.ConstructorDescriptor;
|
||||
import org.jetbrains.kotlin.descriptors.ValueParameterDescriptor;
|
||||
import org.jetbrains.kotlin.descriptors.*;
|
||||
import org.jetbrains.kotlin.load.java.structure.*;
|
||||
import org.jetbrains.kotlin.name.FqName;
|
||||
import org.jetbrains.kotlin.name.Name;
|
||||
@@ -106,7 +103,7 @@ public final class DescriptorResolverUtils {
|
||||
|
||||
@Nullable
|
||||
public static ValueParameterDescriptor getAnnotationParameterByName(@NotNull Name name, @NotNull ClassDescriptor annotationClass) {
|
||||
Collection<ConstructorDescriptor> constructors = annotationClass.getConstructors();
|
||||
Collection<ClassConstructorDescriptor> constructors = annotationClass.getConstructors();
|
||||
if (constructors.size() != 1) return null;
|
||||
|
||||
for (ValueParameterDescriptor parameter : constructors.iterator().next().getValueParameters()) {
|
||||
|
||||
+14
-14
@@ -20,19 +20,19 @@ import org.jetbrains.annotations.NotNull;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
import org.jetbrains.kotlin.descriptors.*;
|
||||
import org.jetbrains.kotlin.descriptors.annotations.Annotations;
|
||||
import org.jetbrains.kotlin.descriptors.impl.ConstructorDescriptorImpl;
|
||||
import org.jetbrains.kotlin.descriptors.impl.ClassConstructorDescriptorImpl;
|
||||
import org.jetbrains.kotlin.name.Name;
|
||||
import org.jetbrains.kotlin.types.KotlinType;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
public class JavaConstructorDescriptor extends ConstructorDescriptorImpl implements JavaCallableMemberDescriptor {
|
||||
public class JavaClassConstructorDescriptor extends ClassConstructorDescriptorImpl implements JavaCallableMemberDescriptor {
|
||||
private Boolean hasStableParameterNames = null;
|
||||
private Boolean hasSynthesizedParameterNames = null;
|
||||
|
||||
protected JavaConstructorDescriptor(
|
||||
protected JavaClassConstructorDescriptor(
|
||||
@NotNull ClassDescriptor containingDeclaration,
|
||||
@Nullable JavaConstructorDescriptor original,
|
||||
@Nullable JavaClassConstructorDescriptor original,
|
||||
@NotNull Annotations annotations,
|
||||
boolean isPrimary,
|
||||
@NotNull Kind kind,
|
||||
@@ -42,13 +42,13 @@ public class JavaConstructorDescriptor extends ConstructorDescriptorImpl impleme
|
||||
}
|
||||
|
||||
@NotNull
|
||||
public static JavaConstructorDescriptor createJavaConstructor(
|
||||
public static JavaClassConstructorDescriptor createJavaConstructor(
|
||||
@NotNull ClassDescriptor containingDeclaration,
|
||||
@NotNull Annotations annotations,
|
||||
boolean isPrimary,
|
||||
@NotNull SourceElement source
|
||||
) {
|
||||
return new JavaConstructorDescriptor(containingDeclaration, null, annotations, isPrimary, Kind.DECLARATION, source);
|
||||
return new JavaClassConstructorDescriptor(containingDeclaration, null, annotations, isPrimary, Kind.DECLARATION, source);
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -73,7 +73,7 @@ public class JavaConstructorDescriptor extends ConstructorDescriptorImpl impleme
|
||||
|
||||
@NotNull
|
||||
@Override
|
||||
protected JavaConstructorDescriptor createSubstitutedCopy(
|
||||
protected JavaClassConstructorDescriptor createSubstitutedCopy(
|
||||
@NotNull DeclarationDescriptor newOwner,
|
||||
@Nullable FunctionDescriptor original,
|
||||
@NotNull Kind kind,
|
||||
@@ -92,22 +92,22 @@ public class JavaConstructorDescriptor extends ConstructorDescriptorImpl impleme
|
||||
|
||||
assert newName == null : "Attempt to rename constructor: " + this;
|
||||
|
||||
JavaConstructorDescriptor result =
|
||||
createDescriptor((ClassDescriptor) newOwner, (JavaConstructorDescriptor) original, kind, source, annotations);
|
||||
JavaClassConstructorDescriptor result =
|
||||
createDescriptor((ClassDescriptor) newOwner, (JavaClassConstructorDescriptor) original, kind, source, annotations);
|
||||
result.setHasStableParameterNames(hasStableParameterNames());
|
||||
result.setHasSynthesizedParameterNames(hasSynthesizedParameterNames());
|
||||
return result;
|
||||
}
|
||||
|
||||
@NotNull
|
||||
protected JavaConstructorDescriptor createDescriptor(
|
||||
protected JavaClassConstructorDescriptor createDescriptor(
|
||||
@NotNull ClassDescriptor newOwner,
|
||||
@Nullable JavaConstructorDescriptor original,
|
||||
@Nullable JavaClassConstructorDescriptor original,
|
||||
@NotNull Kind kind,
|
||||
@NotNull SourceElement sourceElement,
|
||||
@NotNull Annotations annotations
|
||||
) {
|
||||
return new JavaConstructorDescriptor(
|
||||
return new JavaClassConstructorDescriptor(
|
||||
newOwner, original, annotations, isPrimary, kind,
|
||||
sourceElement
|
||||
);
|
||||
@@ -115,12 +115,12 @@ public class JavaConstructorDescriptor extends ConstructorDescriptorImpl impleme
|
||||
|
||||
@Override
|
||||
@NotNull
|
||||
public JavaConstructorDescriptor enhance(
|
||||
public JavaClassConstructorDescriptor enhance(
|
||||
@Nullable KotlinType enhancedReceiverType,
|
||||
@NotNull List<KotlinType> enhancedValueParametersTypes,
|
||||
@NotNull KotlinType enhancedReturnType
|
||||
) {
|
||||
JavaConstructorDescriptor enhanced = createSubstitutedCopy(
|
||||
JavaClassConstructorDescriptor enhanced = createSubstitutedCopy(
|
||||
getContainingDeclaration(), /* original = */ null, getKind(), null, getAnnotations(), getSource());
|
||||
// We do not use doSubstitute here as in JavaMethodDescriptor.enhance because type parameters of constructor belongs to class
|
||||
enhanced.initialize(
|
||||
+1
-1
@@ -108,7 +108,7 @@ class LazyJavaClassDescriptor(
|
||||
private val staticScope = LazyJavaStaticClassScope(c, jClass, this)
|
||||
override fun getStaticScope(): MemberScope = staticScope
|
||||
|
||||
override fun getUnsubstitutedPrimaryConstructor(): ConstructorDescriptor? = null
|
||||
override fun getUnsubstitutedPrimaryConstructor(): ClassConstructorDescriptor? = null
|
||||
|
||||
override fun getCompanionObjectDescriptor(): ClassDescriptor? = null
|
||||
|
||||
|
||||
+8
-8
@@ -19,7 +19,7 @@ package org.jetbrains.kotlin.load.java.lazy.descriptors
|
||||
import org.jetbrains.kotlin.builtins.KotlinBuiltIns
|
||||
import org.jetbrains.kotlin.descriptors.*
|
||||
import org.jetbrains.kotlin.descriptors.annotations.Annotations
|
||||
import org.jetbrains.kotlin.descriptors.impl.ConstructorDescriptorImpl
|
||||
import org.jetbrains.kotlin.descriptors.impl.ClassConstructorDescriptorImpl
|
||||
import org.jetbrains.kotlin.descriptors.impl.EnumEntrySyntheticClassDescriptor
|
||||
import org.jetbrains.kotlin.descriptors.impl.ValueParameterDescriptorImpl
|
||||
import org.jetbrains.kotlin.incremental.components.LookupLocation
|
||||
@@ -32,7 +32,7 @@ import org.jetbrains.kotlin.load.java.BuiltinMethodsWithSpecialGenericSignature.
|
||||
import org.jetbrains.kotlin.load.java.BuiltinSpecialProperties.getBuiltinSpecialPropertyGetterName
|
||||
import org.jetbrains.kotlin.load.java.components.DescriptorResolverUtils.resolveOverridesForNonStaticMembers
|
||||
import org.jetbrains.kotlin.load.java.components.TypeUsage
|
||||
import org.jetbrains.kotlin.load.java.descriptors.JavaConstructorDescriptor
|
||||
import org.jetbrains.kotlin.load.java.descriptors.JavaClassConstructorDescriptor
|
||||
import org.jetbrains.kotlin.load.java.descriptors.JavaMethodDescriptor
|
||||
import org.jetbrains.kotlin.load.java.descriptors.JavaPropertyDescriptor
|
||||
import org.jetbrains.kotlin.load.java.descriptors.copyValueParameters
|
||||
@@ -79,7 +79,7 @@ class LazyJavaClassMemberScope(
|
||||
|
||||
internal val constructors = c.storageManager.createLazyValue {
|
||||
val constructors = jClass.constructors
|
||||
val result = ArrayList<JavaConstructorDescriptor>(constructors.size)
|
||||
val result = ArrayList<JavaClassConstructorDescriptor>(constructors.size)
|
||||
for (constructor in constructors) {
|
||||
val descriptor = resolveConstructor(constructor)
|
||||
result.add(descriptor)
|
||||
@@ -505,10 +505,10 @@ class LazyJavaClassMemberScope(
|
||||
&& !doesOverride(builtinWithErasedParameters)
|
||||
}
|
||||
|
||||
private fun resolveConstructor(constructor: JavaConstructor): JavaConstructorDescriptor {
|
||||
private fun resolveConstructor(constructor: JavaConstructor): JavaClassConstructorDescriptor {
|
||||
val classDescriptor = ownerDescriptor
|
||||
|
||||
val constructorDescriptor = JavaConstructorDescriptor.createJavaConstructor(
|
||||
val constructorDescriptor = JavaClassConstructorDescriptor.createJavaConstructor(
|
||||
classDescriptor, c.resolveAnnotations(constructor), /* isPrimary = */ false, c.components.sourceElementFactory.source(constructor)
|
||||
)
|
||||
|
||||
@@ -530,13 +530,13 @@ class LazyJavaClassMemberScope(
|
||||
return constructorDescriptor
|
||||
}
|
||||
|
||||
private fun createDefaultConstructor(): ConstructorDescriptor? {
|
||||
private fun createDefaultConstructor(): ClassConstructorDescriptor? {
|
||||
val isAnnotation: Boolean = jClass.isAnnotationType
|
||||
if (jClass.isInterface && !isAnnotation)
|
||||
return null
|
||||
|
||||
val classDescriptor = ownerDescriptor
|
||||
val constructorDescriptor = JavaConstructorDescriptor.createJavaConstructor(
|
||||
val constructorDescriptor = JavaClassConstructorDescriptor.createJavaConstructor(
|
||||
classDescriptor, Annotations.EMPTY, /* isPrimary = */ true, c.components.sourceElementFactory.source(jClass)
|
||||
)
|
||||
val valueParameters = if (isAnnotation) createAnnotationConstructorParameters(constructorDescriptor)
|
||||
@@ -558,7 +558,7 @@ class LazyJavaClassMemberScope(
|
||||
return visibility
|
||||
}
|
||||
|
||||
private fun createAnnotationConstructorParameters(constructor: ConstructorDescriptorImpl): List<ValueParameterDescriptor> {
|
||||
private fun createAnnotationConstructorParameters(constructor: ClassConstructorDescriptorImpl): List<ValueParameterDescriptor> {
|
||||
val methods = jClass.methods
|
||||
val result = ArrayList<ValueParameterDescriptor>(methods.size)
|
||||
|
||||
|
||||
+2
-2
@@ -231,7 +231,7 @@ open class JvmBuiltInsSettings(
|
||||
return ownerModuleDescriptor.resolveClassByFqName(javaAnalogueFqName, NoLookupLocation.FROM_BUILTINS) as? LazyJavaClassDescriptor
|
||||
}
|
||||
|
||||
override fun getConstructors(classDescriptor: DeserializedClassDescriptor): Collection<ConstructorDescriptor> {
|
||||
override fun getConstructors(classDescriptor: DeserializedClassDescriptor): Collection<ClassConstructorDescriptor> {
|
||||
if (classDescriptor.kind != ClassKind.CLASS) return emptyList()
|
||||
|
||||
val javaAnalogueDescriptor = classDescriptor.getJavaAnalogue() ?: return emptyList()
|
||||
@@ -264,7 +264,7 @@ open class JvmBuiltInsSettings(
|
||||
setAdditionalAnnotations(notConsideredDeprecation)
|
||||
}
|
||||
|
||||
}.build() as ConstructorDescriptor
|
||||
}.build() as ClassConstructorDescriptor
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user