ClassDescriptor is now a super-interface for ClassConstructorDescriptor and TypeAliasConstructorDescriptor.
This commit is contained in:
committed by
Dmitry Petrov
parent
7d214c6e58
commit
796d11c860
+11
-5
@@ -23,28 +23,34 @@ import org.jetbrains.kotlin.types.KotlinType
|
||||
import org.jetbrains.kotlin.types.TypeSubstitutor
|
||||
|
||||
class AccessorForConstructorDescriptor(
|
||||
private val calleeDescriptor: ConstructorDescriptor,
|
||||
private val calleeDescriptor: ClassConstructorDescriptor,
|
||||
containingDeclaration: DeclarationDescriptor,
|
||||
private val superCallTarget: ClassDescriptor?
|
||||
) : AbstractAccessorForFunctionDescriptor(containingDeclaration, Name.special("<init>")),
|
||||
ConstructorDescriptor,
|
||||
ClassConstructorDescriptor,
|
||||
AccessorForCallableDescriptor<ConstructorDescriptor> {
|
||||
override fun getCalleeDescriptor(): ConstructorDescriptor = calleeDescriptor
|
||||
|
||||
override fun getContainingDeclaration(): ClassDescriptor = calleeDescriptor.containingDeclaration
|
||||
|
||||
override fun getConstructedClass(): ClassDescriptor = calleeDescriptor.constructedClass
|
||||
|
||||
override fun isPrimary(): Boolean = false
|
||||
|
||||
override fun getReturnType(): KotlinType = super.getReturnType()!!
|
||||
|
||||
override fun getSuperCallTarget(): ClassDescriptor? = superCallTarget
|
||||
|
||||
override fun substitute(substitutor: TypeSubstitutor) = super.substitute(substitutor) as ConstructorDescriptor
|
||||
override fun substitute(substitutor: TypeSubstitutor) = super.substitute(substitutor) as ClassConstructorDescriptor
|
||||
|
||||
override fun copy(
|
||||
newOwner: DeclarationDescriptor?, modality: Modality?, visibility: Visibility?, kind: CallableMemberDescriptor.Kind?, copyOverrides: Boolean
|
||||
newOwner: DeclarationDescriptor,
|
||||
modality: Modality,
|
||||
visibility: Visibility,
|
||||
kind: CallableMemberDescriptor.Kind,
|
||||
copyOverrides: Boolean
|
||||
): AccessorForConstructorDescriptor {
|
||||
throw UnsupportedOperationException("Trying to copy synthetic accessor $this")
|
||||
throw UnsupportedOperationException()
|
||||
}
|
||||
|
||||
override fun getOriginal(): AccessorForConstructorDescriptor = this
|
||||
|
||||
+1
-1
@@ -227,7 +227,7 @@ class DefaultParameterValueSubstitutor(val state: GenerationState) {
|
||||
}
|
||||
|
||||
private fun isEmptyConstructorNeeded(constructorDescriptor: ConstructorDescriptor, classOrObject: KtClassOrObject): Boolean {
|
||||
val classDescriptor = constructorDescriptor.containingDeclaration
|
||||
val classDescriptor = constructorDescriptor.constructedClass
|
||||
if (classDescriptor.kind != ClassKind.CLASS) return false
|
||||
|
||||
if (classOrObject.isLocal()) return false
|
||||
|
||||
@@ -1643,7 +1643,7 @@ public class ExpressionCodegen extends KtVisitor<StackValue, StackValue> impleme
|
||||
|
||||
ConstructorDescriptor primaryConstructor = classDescriptor.getUnsubstitutedPrimaryConstructor();
|
||||
assert primaryConstructor != null : "There should be primary constructor for object literal";
|
||||
ResolvedCall<ConstructorDescriptor> superCall = getDelegationConstructorCall(bindingContext, primaryConstructor);
|
||||
ResolvedCall<ClassConstructorDescriptor> superCall = getDelegationConstructorCall(bindingContext, primaryConstructor);
|
||||
if (superCall != null) {
|
||||
// For an anonymous object, we should also generate all non-default arguments that it captures for its super call
|
||||
ConstructorDescriptor superConstructor = superCall.getResultingDescriptor();
|
||||
@@ -1672,7 +1672,7 @@ public class ExpressionCodegen extends KtVisitor<StackValue, StackValue> impleme
|
||||
argumentGenerator.generate(valueArguments, valueArguments);
|
||||
}
|
||||
|
||||
Collection<ConstructorDescriptor> constructors = classDescriptor.getConstructors();
|
||||
Collection<ClassConstructorDescriptor> constructors = classDescriptor.getConstructors();
|
||||
assert constructors.size() == 1 : "Unexpected number of constructors for class: " + classDescriptor + " " + constructors;
|
||||
ConstructorDescriptor constructorDescriptor = CollectionsKt.single(constructors);
|
||||
|
||||
@@ -3984,11 +3984,11 @@ public class ExpressionCodegen extends KtVisitor<StackValue, StackValue> impleme
|
||||
}
|
||||
|
||||
@NotNull
|
||||
public ConstructorDescriptor getConstructorDescriptor(@NotNull ResolvedCall<?> resolvedCall) {
|
||||
public ClassConstructorDescriptor getConstructorDescriptor(@NotNull ResolvedCall<?> resolvedCall) {
|
||||
FunctionDescriptor accessibleDescriptor = accessibleFunctionDescriptor(resolvedCall);
|
||||
assert accessibleDescriptor instanceof ConstructorDescriptor :
|
||||
"getConstructorDescriptor must be called only for constructors: " + accessibleDescriptor;
|
||||
return (ConstructorDescriptor) accessibleDescriptor;
|
||||
return (ClassConstructorDescriptor) accessibleDescriptor;
|
||||
}
|
||||
|
||||
@NotNull
|
||||
@@ -3999,7 +3999,7 @@ public class ExpressionCodegen extends KtVisitor<StackValue, StackValue> impleme
|
||||
v.anew(objectType);
|
||||
v.dup();
|
||||
|
||||
ConstructorDescriptor constructor = getConstructorDescriptor(resolvedCall);
|
||||
ClassConstructorDescriptor constructor = getConstructorDescriptor(resolvedCall);
|
||||
|
||||
ReceiverParameterDescriptor dispatchReceiver = constructor.getDispatchReceiverParameter();
|
||||
ClassDescriptor containingDeclaration = constructor.getContainingDeclaration();
|
||||
|
||||
@@ -383,7 +383,7 @@ public class ImplementationBodyCodegen extends ClassBodyCodegen {
|
||||
try {
|
||||
lookupConstructorExpressionsInClosureIfPresent();
|
||||
generatePrimaryConstructor(delegationFieldsInfo);
|
||||
for (ConstructorDescriptor secondaryConstructor : DescriptorUtilsKt.getSecondaryConstructors(descriptor)) {
|
||||
for (ClassConstructorDescriptor secondaryConstructor : DescriptorUtilsKt.getSecondaryConstructors(descriptor)) {
|
||||
generateSecondaryConstructor(secondaryConstructor);
|
||||
}
|
||||
}
|
||||
@@ -919,7 +919,7 @@ public class ImplementationBodyCodegen extends ClassBodyCodegen {
|
||||
private void generatePrimaryConstructor(final DelegationFieldsInfo delegationFieldsInfo) {
|
||||
if (isInterface(descriptor) || isAnnotationClass(descriptor)) return;
|
||||
|
||||
final ConstructorDescriptor constructorDescriptor = descriptor.getUnsubstitutedPrimaryConstructor();
|
||||
final ClassConstructorDescriptor constructorDescriptor = descriptor.getUnsubstitutedPrimaryConstructor();
|
||||
if (constructorDescriptor == null) return;
|
||||
|
||||
ConstructorContext constructorContext = context.intoConstructor(constructorDescriptor);
|
||||
@@ -942,7 +942,7 @@ public class ImplementationBodyCodegen extends ClassBodyCodegen {
|
||||
new DefaultParameterValueSubstitutor(state).generatePrimaryConstructorOverloadsIfNeeded(constructorDescriptor, v, this, kind, myClass);
|
||||
}
|
||||
|
||||
private void generateSecondaryConstructor(@NotNull final ConstructorDescriptor constructorDescriptor) {
|
||||
private void generateSecondaryConstructor(@NotNull final ClassConstructorDescriptor constructorDescriptor) {
|
||||
if (!canHaveDeclaredConstructors(descriptor)) return;
|
||||
|
||||
ConstructorContext constructorContext = context.intoConstructor(constructorDescriptor);
|
||||
@@ -969,7 +969,7 @@ public class ImplementationBodyCodegen extends ClassBodyCodegen {
|
||||
}
|
||||
|
||||
private void generatePrimaryConstructorImpl(
|
||||
@NotNull ConstructorDescriptor constructorDescriptor,
|
||||
@NotNull ClassConstructorDescriptor constructorDescriptor,
|
||||
@NotNull ExpressionCodegen codegen,
|
||||
@NotNull DelegationFieldsInfo fieldsInfo,
|
||||
@Nullable KtPrimaryConstructor primaryConstructor
|
||||
@@ -1030,7 +1030,7 @@ public class ImplementationBodyCodegen extends ClassBodyCodegen {
|
||||
}
|
||||
|
||||
private void generateSecondaryConstructorImpl(
|
||||
@NotNull ConstructorDescriptor constructorDescriptor,
|
||||
@NotNull ClassConstructorDescriptor constructorDescriptor,
|
||||
@NotNull ExpressionCodegen codegen
|
||||
) {
|
||||
InstructionAdapter iv = codegen.v;
|
||||
@@ -1040,7 +1040,7 @@ public class ImplementationBodyCodegen extends ClassBodyCodegen {
|
||||
|
||||
markLineNumberForConstructor(constructorDescriptor, constructor, codegen);
|
||||
|
||||
ResolvedCall<ConstructorDescriptor> constructorDelegationCall =
|
||||
ResolvedCall<ClassConstructorDescriptor> constructorDelegationCall =
|
||||
getDelegationConstructorCall(bindingContext, constructorDescriptor);
|
||||
ConstructorDescriptor delegateConstructor = constructorDelegationCall == null ? null :
|
||||
constructorDelegationCall.getResultingDescriptor();
|
||||
@@ -1061,7 +1061,7 @@ public class ImplementationBodyCodegen extends ClassBodyCodegen {
|
||||
}
|
||||
|
||||
private static void markLineNumberForConstructor(
|
||||
@NotNull ConstructorDescriptor descriptor,
|
||||
@NotNull ClassConstructorDescriptor descriptor,
|
||||
@Nullable KtConstructor constructor,
|
||||
@NotNull ExpressionCodegen codegen
|
||||
) {
|
||||
@@ -1365,8 +1365,8 @@ public class ImplementationBodyCodegen extends ClassBodyCodegen {
|
||||
private void generateDelegatorToConstructorCall(
|
||||
@NotNull InstructionAdapter iv,
|
||||
@NotNull ExpressionCodegen codegen,
|
||||
@NotNull ConstructorDescriptor constructorDescriptor,
|
||||
@Nullable ResolvedCall<ConstructorDescriptor> delegationConstructorCall
|
||||
@NotNull ClassConstructorDescriptor constructorDescriptor,
|
||||
@Nullable ResolvedCall<ClassConstructorDescriptor> delegationConstructorCall
|
||||
) {
|
||||
if (delegationConstructorCall == null) {
|
||||
genSimpleSuperCall(iv);
|
||||
|
||||
@@ -21,7 +21,7 @@ import org.jetbrains.annotations.Nullable;
|
||||
import org.jetbrains.kotlin.descriptors.*;
|
||||
import org.jetbrains.kotlin.descriptors.annotations.Annotations;
|
||||
import org.jetbrains.kotlin.descriptors.impl.ClassDescriptorBase;
|
||||
import org.jetbrains.kotlin.descriptors.impl.ConstructorDescriptorImpl;
|
||||
import org.jetbrains.kotlin.descriptors.impl.ClassConstructorDescriptorImpl;
|
||||
import org.jetbrains.kotlin.descriptors.impl.DeclarationDescriptorImpl;
|
||||
import org.jetbrains.kotlin.name.Name;
|
||||
import org.jetbrains.kotlin.resolve.scopes.MemberScope;
|
||||
@@ -126,13 +126,13 @@ public class MutableClassDescriptor extends ClassDescriptorBase implements Class
|
||||
|
||||
@NotNull
|
||||
@Override
|
||||
public Set<ConstructorDescriptor> getConstructors() {
|
||||
public Set<ClassConstructorDescriptor> getConstructors() {
|
||||
return Collections.emptySet();
|
||||
}
|
||||
|
||||
@Override
|
||||
@Nullable
|
||||
public ConstructorDescriptor getUnsubstitutedPrimaryConstructor() {
|
||||
public ClassConstructorDescriptor getUnsubstitutedPrimaryConstructor() {
|
||||
return null;
|
||||
}
|
||||
|
||||
@@ -155,7 +155,7 @@ public class MutableClassDescriptor extends ClassDescriptorBase implements Class
|
||||
this, Annotations.Companion.getEMPTY(), ModalityKt.isFinalClass(this), typeParameters, supertypes
|
||||
);
|
||||
for (FunctionDescriptor functionDescriptor : getConstructors()) {
|
||||
((ConstructorDescriptorImpl) functionDescriptor).setReturnType(getDefaultType());
|
||||
((ClassConstructorDescriptorImpl) functionDescriptor).setReturnType(getDefaultType());
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -449,8 +449,8 @@ public abstract class CodegenContext<T extends DeclarationDescriptor> {
|
||||
(FunctionDescriptor) descriptor, contextDescriptor, superCallTarget, nameSuffix
|
||||
);
|
||||
}
|
||||
else if (descriptor instanceof ConstructorDescriptor) {
|
||||
accessor = new AccessorForConstructorDescriptor((ConstructorDescriptor) descriptor, contextDescriptor, superCallTarget);
|
||||
else if (descriptor instanceof ClassConstructorDescriptor) {
|
||||
accessor = new AccessorForConstructorDescriptor((ClassConstructorDescriptor) descriptor, contextDescriptor, superCallTarget);
|
||||
}
|
||||
else if (descriptor instanceof PropertyDescriptor) {
|
||||
PropertyDescriptor propertyDescriptor = (PropertyDescriptor) descriptor;
|
||||
@@ -584,8 +584,8 @@ public abstract class CodegenContext<T extends DeclarationDescriptor> {
|
||||
descriptorContext = ExpressionCodegen.getParentContextSubclassOf((ClassDescriptor) enclosed, this);
|
||||
}
|
||||
|
||||
if (descriptorContext == null && descriptor instanceof ConstructorDescriptor) {
|
||||
ClassDescriptor classDescriptor = ((ConstructorDescriptor) descriptor).getContainingDeclaration();
|
||||
if (descriptorContext == null && descriptor instanceof ClassConstructorDescriptor) {
|
||||
ClassDescriptor classDescriptor = ((ClassConstructorDescriptor) descriptor).getContainingDeclaration();
|
||||
if (DescriptorUtils.isSealedClass(classDescriptor)) {
|
||||
CodegenContext parentContextForClass = findParentContextWithDescriptor(classDescriptor.getContainingDeclaration());
|
||||
if (parentContextForClass != null) {
|
||||
|
||||
+1
-1
@@ -27,7 +27,7 @@ internal class FictitiousArrayConstructor(arrayClass: ClassDescriptor) : SimpleF
|
||||
companion object Factory {
|
||||
@JvmStatic
|
||||
fun create(arrayConstructor: ConstructorDescriptor): FictitiousArrayConstructor {
|
||||
val arrayClass = arrayConstructor.containingDeclaration
|
||||
val arrayClass = arrayConstructor.constructedClass
|
||||
return FictitiousArrayConstructor(arrayClass).apply {
|
||||
this.initialize(null, null, arrayConstructor.typeParameters, arrayConstructor.valueParameters, arrayClass.defaultType,
|
||||
Modality.FINAL, Visibilities.PUBLIC)
|
||||
|
||||
@@ -929,9 +929,9 @@ public class KotlinTypeMapper {
|
||||
? new JvmSignatureWriter()
|
||||
: new BothSignatureWriter(BothSignatureWriter.Mode.METHOD);
|
||||
|
||||
if (f instanceof ConstructorDescriptor) {
|
||||
if (f instanceof ClassConstructorDescriptor) {
|
||||
sw.writeParametersStart();
|
||||
writeAdditionalConstructorParameters((ConstructorDescriptor) f, sw);
|
||||
writeAdditionalConstructorParameters((ClassConstructorDescriptor) f, sw);
|
||||
|
||||
for (ValueParameterDescriptor parameter : valueParameters) {
|
||||
writeParameter(sw, parameter.getType(), f);
|
||||
@@ -1211,7 +1211,7 @@ public class KotlinTypeMapper {
|
||||
sw.writeParameterTypeEnd();
|
||||
}
|
||||
|
||||
private void writeAdditionalConstructorParameters(@NotNull ConstructorDescriptor descriptor, @NotNull JvmSignatureWriter sw) {
|
||||
private void writeAdditionalConstructorParameters(@NotNull ClassConstructorDescriptor descriptor, @NotNull JvmSignatureWriter sw) {
|
||||
MutableClosure closure = bindingContext.get(CodegenBinding.CLOSURE, descriptor.getContainingDeclaration());
|
||||
|
||||
ClassDescriptor captureThis = getDispatchReceiverParameterForConstructorCall(descriptor, closure);
|
||||
@@ -1260,7 +1260,7 @@ public class KotlinTypeMapper {
|
||||
// We may generate a slightly wrong signature for a local class / anonymous object in light classes mode but we don't care,
|
||||
// because such classes are not accessible from the outside world
|
||||
if (classBuilderMode.generateBodies) {
|
||||
ResolvedCall<ConstructorDescriptor> superCall = findFirstDelegatingSuperCall(descriptor);
|
||||
ResolvedCall<ClassConstructorDescriptor> superCall = findFirstDelegatingSuperCall(descriptor);
|
||||
if (superCall == null) return;
|
||||
writeSuperConstructorCallParameters(sw, descriptor, superCall, captureThis != null);
|
||||
}
|
||||
@@ -1268,8 +1268,8 @@ public class KotlinTypeMapper {
|
||||
|
||||
private void writeSuperConstructorCallParameters(
|
||||
@NotNull JvmSignatureWriter sw,
|
||||
@NotNull ConstructorDescriptor descriptor,
|
||||
@NotNull ResolvedCall<ConstructorDescriptor> superCall,
|
||||
@NotNull ClassConstructorDescriptor descriptor,
|
||||
@NotNull ResolvedCall<ClassConstructorDescriptor> superCall,
|
||||
boolean hasOuter
|
||||
) {
|
||||
ConstructorDescriptor superDescriptor = SamCodegenUtil.resolveSamAdapter(superCall.getResultingDescriptor());
|
||||
@@ -1308,10 +1308,10 @@ public class KotlinTypeMapper {
|
||||
}
|
||||
|
||||
@Nullable
|
||||
private ResolvedCall<ConstructorDescriptor> findFirstDelegatingSuperCall(@NotNull ConstructorDescriptor descriptor) {
|
||||
private ResolvedCall<ClassConstructorDescriptor> findFirstDelegatingSuperCall(@NotNull ClassConstructorDescriptor descriptor) {
|
||||
ClassDescriptor classDescriptor = descriptor.getContainingDeclaration();
|
||||
while (true) {
|
||||
ResolvedCall<ConstructorDescriptor> next = getDelegationConstructorCall(bindingContext, descriptor);
|
||||
ResolvedCall<ClassConstructorDescriptor> next = getDelegationConstructorCall(bindingContext, descriptor);
|
||||
if (next == null) return null;
|
||||
descriptor = next.getResultingDescriptor();
|
||||
if (descriptor.getContainingDeclaration() != classDescriptor) return next;
|
||||
|
||||
+12
-12
@@ -21,14 +21,14 @@ import org.jetbrains.annotations.Nullable;
|
||||
import org.jetbrains.kotlin.descriptors.ClassDescriptor;
|
||||
import org.jetbrains.kotlin.descriptors.SourceElement;
|
||||
import org.jetbrains.kotlin.descriptors.annotations.Annotations;
|
||||
import org.jetbrains.kotlin.load.java.descriptors.JavaConstructorDescriptor;
|
||||
import org.jetbrains.kotlin.load.java.descriptors.JavaClassConstructorDescriptor;
|
||||
import org.jetbrains.kotlin.load.java.descriptors.SamAdapterDescriptor;
|
||||
|
||||
/* package */ class SamAdapterConstructorDescriptor extends JavaConstructorDescriptor
|
||||
implements SamAdapterDescriptor<JavaConstructorDescriptor> {
|
||||
private final JavaConstructorDescriptor declaration;
|
||||
/* package */ class SamAdapterClassConstructorDescriptor extends JavaClassConstructorDescriptor
|
||||
implements SamAdapterDescriptor<JavaClassConstructorDescriptor> {
|
||||
private final JavaClassConstructorDescriptor declaration;
|
||||
|
||||
public SamAdapterConstructorDescriptor(@NotNull JavaConstructorDescriptor declaration) {
|
||||
public SamAdapterClassConstructorDescriptor(@NotNull JavaClassConstructorDescriptor declaration) {
|
||||
super(declaration.getContainingDeclaration(), null, declaration.getAnnotations(),
|
||||
declaration.isPrimary(), Kind.SYNTHESIZED, declaration.getSource());
|
||||
this.declaration = declaration;
|
||||
@@ -36,14 +36,14 @@ import org.jetbrains.kotlin.load.java.descriptors.SamAdapterDescriptor;
|
||||
setHasSynthesizedParameterNames(declaration.hasSynthesizedParameterNames());
|
||||
}
|
||||
|
||||
private SamAdapterConstructorDescriptor(
|
||||
private SamAdapterClassConstructorDescriptor(
|
||||
@NotNull ClassDescriptor containingDeclaration,
|
||||
@Nullable JavaConstructorDescriptor original,
|
||||
@Nullable JavaClassConstructorDescriptor original,
|
||||
@NotNull Annotations annotations,
|
||||
boolean isPrimary,
|
||||
@NotNull Kind kind,
|
||||
@NotNull SourceElement source,
|
||||
@NotNull JavaConstructorDescriptor declaration
|
||||
@NotNull JavaClassConstructorDescriptor declaration
|
||||
) {
|
||||
super(containingDeclaration, original, annotations, isPrimary, kind, source);
|
||||
this.declaration = declaration;
|
||||
@@ -51,19 +51,19 @@ import org.jetbrains.kotlin.load.java.descriptors.SamAdapterDescriptor;
|
||||
|
||||
@NotNull
|
||||
@Override
|
||||
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 SamAdapterConstructorDescriptor(newOwner, original, annotations, isPrimary, kind, sourceElement, declaration);
|
||||
return new SamAdapterClassConstructorDescriptor(newOwner, original, annotations, isPrimary, kind, sourceElement, declaration);
|
||||
}
|
||||
|
||||
@NotNull
|
||||
@Override
|
||||
public JavaConstructorDescriptor getBaseDescriptorForSynthetic() {
|
||||
public JavaClassConstructorDescriptor getBaseDescriptorForSynthetic() {
|
||||
return declaration;
|
||||
}
|
||||
}
|
||||
+2
-2
@@ -21,7 +21,7 @@ import org.jetbrains.kotlin.descriptors.DeclarationDescriptor
|
||||
import org.jetbrains.kotlin.descriptors.FunctionDescriptor
|
||||
import org.jetbrains.kotlin.load.java.components.SamConversionResolver
|
||||
import org.jetbrains.kotlin.load.java.descriptors.JavaClassDescriptor
|
||||
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.SamConstructorDescriptor
|
||||
import org.jetbrains.kotlin.load.java.lazy.descriptors.LazyJavaClassDescriptor
|
||||
@@ -38,7 +38,7 @@ object SamConversionResolverImpl : SamConversionResolver {
|
||||
override fun <D : FunctionDescriptor> resolveSamAdapter(original: D): D? {
|
||||
return when {
|
||||
!SingleAbstractMethodUtils.isSamAdapterNecessary(original) -> null
|
||||
original is JavaConstructorDescriptor -> SingleAbstractMethodUtils.createSamAdapterConstructor(original) as D
|
||||
original is JavaClassConstructorDescriptor -> SingleAbstractMethodUtils.createSamAdapterConstructor(original) as D
|
||||
original is JavaMethodDescriptor -> SingleAbstractMethodUtils.createSamAdapterFunction(original) as D
|
||||
else -> null
|
||||
}
|
||||
|
||||
+3
-3
@@ -205,8 +205,8 @@ public class SingleAbstractMethodUtils {
|
||||
}
|
||||
|
||||
@NotNull
|
||||
public static SamAdapterDescriptor<JavaConstructorDescriptor> createSamAdapterConstructor(@NotNull final JavaConstructorDescriptor original) {
|
||||
final SamAdapterConstructorDescriptor result = new SamAdapterConstructorDescriptor(original);
|
||||
public static SamAdapterDescriptor<JavaClassConstructorDescriptor> createSamAdapterConstructor(@NotNull final JavaClassConstructorDescriptor original) {
|
||||
final SamAdapterClassConstructorDescriptor result = new SamAdapterClassConstructorDescriptor(original);
|
||||
return initSamAdapter(original, result, new FunctionInitializer() {
|
||||
@Override
|
||||
public void initialize(
|
||||
@@ -277,7 +277,7 @@ public class SingleAbstractMethodUtils {
|
||||
@NotNull List<TypeParameterDescriptor> originalParameters,
|
||||
@Nullable DeclarationDescriptor newOwner
|
||||
) {
|
||||
if (newOwner instanceof SamAdapterConstructorDescriptor) {
|
||||
if (newOwner instanceof SamAdapterClassConstructorDescriptor) {
|
||||
return new TypeParameters(originalParameters, TypeSubstitutor.EMPTY);
|
||||
}
|
||||
|
||||
|
||||
+2
-2
@@ -22,7 +22,7 @@ import org.jetbrains.kotlin.descriptors.ValueParameterDescriptor
|
||||
import org.jetbrains.kotlin.diagnostics.DiagnosticFactory0
|
||||
import org.jetbrains.kotlin.load.java.JvmAnnotationNames
|
||||
import org.jetbrains.kotlin.load.java.components.JavaAnnotationMapper
|
||||
import org.jetbrains.kotlin.load.java.descriptors.JavaConstructorDescriptor
|
||||
import org.jetbrains.kotlin.load.java.descriptors.JavaClassConstructorDescriptor
|
||||
import org.jetbrains.kotlin.psi.KtAnnotationEntry
|
||||
import org.jetbrains.kotlin.psi.KtExpression
|
||||
import org.jetbrains.kotlin.resolve.BindingContext
|
||||
@@ -37,7 +37,7 @@ import org.jetbrains.kotlin.resolve.jvm.diagnostics.ErrorsJvm
|
||||
class JavaAnnotationCallChecker : CallChecker {
|
||||
override fun check(resolvedCall: ResolvedCall<*>, reportOn: PsiElement, context: CallCheckerContext) {
|
||||
val resultingDescriptor = resolvedCall.resultingDescriptor.original
|
||||
if (resultingDescriptor !is JavaConstructorDescriptor ||
|
||||
if (resultingDescriptor !is JavaClassConstructorDescriptor ||
|
||||
resultingDescriptor.containingDeclaration.kind != ClassKind.ANNOTATION_CLASS) return
|
||||
|
||||
reportErrorsOnPositionedArguments(resolvedCall, context)
|
||||
|
||||
@@ -169,7 +169,7 @@ public class AnnotationResolver {
|
||||
if (!ErrorUtils.isError(descriptor)) {
|
||||
if (descriptor instanceof ConstructorDescriptor) {
|
||||
ConstructorDescriptor constructor = (ConstructorDescriptor)descriptor;
|
||||
ClassDescriptor classDescriptor = constructor.getContainingDeclaration();
|
||||
ClassDescriptor classDescriptor = constructor.getConstructedClass();
|
||||
if (classDescriptor.getKind() != ClassKind.ANNOTATION_CLASS) {
|
||||
trace.report(NOT_AN_ANNOTATION_CLASS.on(entryElement, classDescriptor));
|
||||
}
|
||||
|
||||
@@ -221,7 +221,7 @@ public interface BindingContext {
|
||||
*/
|
||||
WritableSlice<PsiElement, SimpleFunctionDescriptor> FUNCTION = Slices.createSimpleSlice();
|
||||
WritableSlice<PsiElement, ConstructorDescriptor> CONSTRUCTOR = Slices.createSimpleSlice();
|
||||
WritableSlice<ConstructorDescriptor, ResolvedCall<ConstructorDescriptor>> CONSTRUCTOR_RESOLVED_DELEGATION_CALL =
|
||||
WritableSlice<ConstructorDescriptor, ResolvedCall<ClassConstructorDescriptor>> CONSTRUCTOR_RESOLVED_DELEGATION_CALL =
|
||||
Slices.createSimpleSlice();
|
||||
WritableSlice<PsiElement, VariableDescriptor> VARIABLE = Slices.createSimpleSlice();
|
||||
WritableSlice<KtParameter, VariableDescriptor> VALUE_PARAMETER = Slices.createSimpleSlice();
|
||||
|
||||
@@ -222,7 +222,7 @@ public class BindingContextUtils {
|
||||
}
|
||||
|
||||
@Nullable
|
||||
public static ResolvedCall<ConstructorDescriptor> getDelegationConstructorCall(
|
||||
public static ResolvedCall<ClassConstructorDescriptor> getDelegationConstructorCall(
|
||||
@NotNull BindingContext bindingContext,
|
||||
@NotNull ConstructorDescriptor constructorDescriptor
|
||||
) {
|
||||
|
||||
@@ -38,7 +38,7 @@ public interface BodiesResolveContext {
|
||||
@Mutable
|
||||
Map<KtAnonymousInitializer, ClassDescriptorWithResolutionScopes> getAnonymousInitializers();
|
||||
@Mutable
|
||||
Map<KtSecondaryConstructor, ConstructorDescriptor> getSecondaryConstructors();
|
||||
Map<KtSecondaryConstructor, ClassConstructorDescriptor> getSecondaryConstructors();
|
||||
@Mutable
|
||||
Map<KtScript, LazyScriptDescriptor> getScripts();
|
||||
|
||||
|
||||
@@ -122,14 +122,14 @@ public class BodyResolver {
|
||||
}
|
||||
|
||||
private void resolveSecondaryConstructors(@NotNull BodiesResolveContext c) {
|
||||
for (Map.Entry<KtSecondaryConstructor, ConstructorDescriptor> entry : c.getSecondaryConstructors().entrySet()) {
|
||||
for (Map.Entry<KtSecondaryConstructor, ClassConstructorDescriptor> entry : c.getSecondaryConstructors().entrySet()) {
|
||||
LexicalScope declaringScope = c.getDeclaringScope(entry.getKey());
|
||||
assert declaringScope != null : "Declaring scope should be registered before body resolve";
|
||||
resolveSecondaryConstructorBody(c.getOuterDataFlowInfo(), trace, entry.getKey(), entry.getValue(), declaringScope);
|
||||
}
|
||||
if (c.getSecondaryConstructors().isEmpty()) return;
|
||||
Set<ConstructorDescriptor> visitedConstructors = Sets.newHashSet();
|
||||
for (Map.Entry<KtSecondaryConstructor, ConstructorDescriptor> entry : c.getSecondaryConstructors().entrySet()) {
|
||||
for (Map.Entry<KtSecondaryConstructor, ClassConstructorDescriptor> entry : c.getSecondaryConstructors().entrySet()) {
|
||||
checkCyclicConstructorDelegationCall(entry.getValue(), visitedConstructors);
|
||||
}
|
||||
}
|
||||
@@ -138,7 +138,7 @@ public class BodyResolver {
|
||||
@NotNull final DataFlowInfo outerDataFlowInfo,
|
||||
@NotNull final BindingTrace trace,
|
||||
@NotNull final KtSecondaryConstructor constructor,
|
||||
@NotNull final ConstructorDescriptor descriptor,
|
||||
@NotNull final ClassConstructorDescriptor descriptor,
|
||||
@NotNull LexicalScope declaringScope
|
||||
) {
|
||||
ForceResolveUtil.forceResolveAllContents(descriptor.getAnnotations());
|
||||
@@ -167,7 +167,7 @@ public class BodyResolver {
|
||||
@NotNull BindingTrace trace,
|
||||
@NotNull LexicalScope scope,
|
||||
@NotNull KtSecondaryConstructor constructor,
|
||||
@NotNull ConstructorDescriptor descriptor
|
||||
@NotNull ClassConstructorDescriptor descriptor
|
||||
) {
|
||||
OverloadResolutionResults<?> results = callResolver.resolveConstructorDelegationCall(
|
||||
trace, scope, outerDataFlowInfo,
|
||||
@@ -231,7 +231,7 @@ public class BodyResolver {
|
||||
|
||||
@Nullable
|
||||
private ConstructorDescriptor getDelegatedConstructor(@NotNull ConstructorDescriptor constructor) {
|
||||
ResolvedCall<ConstructorDescriptor> call = trace.get(CONSTRUCTOR_RESOLVED_DELEGATION_CALL, constructor);
|
||||
ResolvedCall<ClassConstructorDescriptor> call = trace.get(CONSTRUCTOR_RESOLVED_DELEGATION_CALL, constructor);
|
||||
return call == null || !call.getStatus().isSuccess() ? null : call.getResultingDescriptor().getOriginal();
|
||||
}
|
||||
|
||||
@@ -430,7 +430,7 @@ public class BodyResolver {
|
||||
@NotNull ResolvedCall<?> call
|
||||
) {
|
||||
//noinspection unchecked
|
||||
trace.record(CONSTRUCTOR_RESOLVED_DELEGATION_CALL, constructor, (ResolvedCall<ConstructorDescriptor>) call);
|
||||
trace.record(CONSTRUCTOR_RESOLVED_DELEGATION_CALL, constructor, (ResolvedCall<ClassConstructorDescriptor>) call);
|
||||
}
|
||||
|
||||
private void checkSupertypeList(
|
||||
|
||||
@@ -217,7 +217,7 @@ class DeclarationsChecker(
|
||||
TypeAliasExpander(reportStrategy).expandWithoutAbbreviation(typeAliasExpansion, Annotations.EMPTY)
|
||||
}
|
||||
|
||||
private fun checkConstructorDeclaration(constructorDescriptor: ConstructorDescriptor, declaration: KtDeclaration) {
|
||||
private fun checkConstructorDeclaration(constructorDescriptor: ClassConstructorDescriptor, declaration: KtDeclaration) {
|
||||
declaration.checkTypeReferences()
|
||||
modifiersChecker.checkModifiersForDeclaration(declaration, constructorDescriptor)
|
||||
identifierChecker.checkDeclaration(declaration, trace)
|
||||
@@ -225,7 +225,7 @@ class DeclarationsChecker(
|
||||
checkConstructorVisibility(constructorDescriptor, declaration)
|
||||
}
|
||||
|
||||
private fun checkConstructorVisibility(constructorDescriptor: ConstructorDescriptor, declaration: KtDeclaration) {
|
||||
private fun checkConstructorVisibility(constructorDescriptor: ClassConstructorDescriptor, declaration: KtDeclaration) {
|
||||
val visibilityModifier = declaration.visibilityModifier()
|
||||
if (visibilityModifier != null && visibilityModifier.node?.elementType != KtTokens.PRIVATE_KEYWORD) {
|
||||
val classDescriptor = constructorDescriptor.containingDeclaration
|
||||
|
||||
@@ -396,12 +396,12 @@ public class DescriptorResolver {
|
||||
}
|
||||
|
||||
@NotNull
|
||||
public static ConstructorDescriptorImpl createAndRecordPrimaryConstructorForObject(
|
||||
public static ClassConstructorDescriptorImpl createAndRecordPrimaryConstructorForObject(
|
||||
@Nullable KtClassOrObject object,
|
||||
@NotNull ClassDescriptor classDescriptor,
|
||||
@NotNull BindingTrace trace
|
||||
) {
|
||||
ConstructorDescriptorImpl constructorDescriptor =
|
||||
ClassConstructorDescriptorImpl constructorDescriptor =
|
||||
DescriptorFactory.createPrimaryConstructorForObject(classDescriptor, KotlinSourceElementKt.toSourceElement(object));
|
||||
if (object != null) {
|
||||
KtPrimaryConstructor primaryConstructor = object.getPrimaryConstructor();
|
||||
|
||||
@@ -19,7 +19,7 @@ package org.jetbrains.kotlin.resolve
|
||||
import org.jetbrains.kotlin.builtins.*
|
||||
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.FunctionExpressionDescriptor
|
||||
import org.jetbrains.kotlin.descriptors.impl.SimpleFunctionDescriptorImpl
|
||||
import org.jetbrains.kotlin.descriptors.impl.ValueParameterDescriptorImpl
|
||||
@@ -239,7 +239,7 @@ class FunctionDescriptorResolver(
|
||||
classDescriptor: ClassDescriptor,
|
||||
classElement: KtClassOrObject,
|
||||
trace: BindingTrace
|
||||
): ConstructorDescriptorImpl? {
|
||||
): ClassConstructorDescriptorImpl? {
|
||||
if (classDescriptor.getKind() == ClassKind.ENUM_ENTRY || !classElement.hasPrimaryConstructor()) return null
|
||||
return createConstructorDescriptor(
|
||||
scope,
|
||||
@@ -257,7 +257,7 @@ class FunctionDescriptorResolver(
|
||||
classDescriptor: ClassDescriptor,
|
||||
constructor: KtSecondaryConstructor,
|
||||
trace: BindingTrace
|
||||
): ConstructorDescriptorImpl {
|
||||
): ClassConstructorDescriptorImpl {
|
||||
return createConstructorDescriptor(
|
||||
scope,
|
||||
classDescriptor,
|
||||
@@ -277,8 +277,8 @@ class FunctionDescriptorResolver(
|
||||
declarationToTrace: KtDeclaration,
|
||||
valueParameters: List<KtParameter>,
|
||||
trace: BindingTrace
|
||||
): ConstructorDescriptorImpl {
|
||||
val constructorDescriptor = ConstructorDescriptorImpl.create(
|
||||
): ClassConstructorDescriptorImpl {
|
||||
val constructorDescriptor = ClassConstructorDescriptorImpl.create(
|
||||
classDescriptor,
|
||||
annotationResolver.resolveAnnotationsWithoutArguments(scope, modifierList, trace),
|
||||
isPrimary,
|
||||
|
||||
@@ -147,7 +147,7 @@ class LazyTopDownAnalyzer(
|
||||
}
|
||||
|
||||
override fun visitSecondaryConstructor(constructor: KtSecondaryConstructor) {
|
||||
c.secondaryConstructors.put(constructor, lazyDeclarationResolver.resolveToDescriptor(constructor) as ConstructorDescriptor)
|
||||
c.secondaryConstructors.put(constructor, lazyDeclarationResolver.resolveToDescriptor(constructor) as ClassConstructorDescriptor)
|
||||
}
|
||||
|
||||
override fun visitEnumEntry(enumEntry: KtEnumEntry) {
|
||||
|
||||
@@ -40,7 +40,7 @@ public class TopDownAnalysisContext implements BodiesResolveContext {
|
||||
private final Map<KtClassOrObject, ClassDescriptorWithResolutionScopes> classes = Maps.newLinkedHashMap();
|
||||
private final Map<KtAnonymousInitializer, ClassDescriptorWithResolutionScopes> anonymousInitializers = Maps.newLinkedHashMap();
|
||||
private final Set<KtFile> files = new LinkedHashSet<KtFile>();
|
||||
private final Map<KtSecondaryConstructor, ConstructorDescriptor> secondaryConstructors = Maps.newLinkedHashMap();
|
||||
private final Map<KtSecondaryConstructor, ClassConstructorDescriptor> secondaryConstructors = Maps.newLinkedHashMap();
|
||||
|
||||
private final Map<KtNamedFunction, SimpleFunctionDescriptor> functions = Maps.newLinkedHashMap();
|
||||
private final Map<KtProperty, PropertyDescriptor> properties = Maps.newLinkedHashMap();
|
||||
@@ -101,7 +101,7 @@ public class TopDownAnalysisContext implements BodiesResolveContext {
|
||||
}
|
||||
|
||||
@Override
|
||||
public Map<KtSecondaryConstructor, ConstructorDescriptor> getSecondaryConstructors() {
|
||||
public Map<KtSecondaryConstructor, ClassConstructorDescriptor> getSecondaryConstructors() {
|
||||
return secondaryConstructors;
|
||||
}
|
||||
|
||||
|
||||
@@ -280,7 +280,7 @@ public class CallResolver {
|
||||
DeclarationDescriptor container = context.scope.getOwnerDescriptor();
|
||||
assert container instanceof ConstructorDescriptor : "Trying to resolve JetConstructorDelegationCall not in constructor. scope.ownerDescriptor = " + container;
|
||||
return (OverloadResolutionResults) resolveConstructorDelegationCall(context, delegationCall, (KtConstructorDelegationReferenceExpression) calleeExpression,
|
||||
(ConstructorDescriptor) container);
|
||||
(ClassConstructorDescriptor) container);
|
||||
}
|
||||
else if (calleeExpression == null) {
|
||||
return checkArgumentTypesAndFail(context);
|
||||
@@ -308,7 +308,7 @@ public class CallResolver {
|
||||
return resolveCallForInvoke(context.replaceCall(call), tracingForInvoke);
|
||||
}
|
||||
|
||||
private OverloadResolutionResults<ConstructorDescriptor> resolveCallForConstructor(
|
||||
private OverloadResolutionResults<ClassConstructorDescriptor> resolveCallForConstructor(
|
||||
@NotNull BasicCallResolutionContext context,
|
||||
@NotNull KtConstructorCalleeExpression expression
|
||||
) {
|
||||
@@ -335,25 +335,25 @@ public class CallResolver {
|
||||
|
||||
ClassDescriptor classDescriptor = (ClassDescriptor) declarationDescriptor;
|
||||
|
||||
Collection<ConstructorDescriptor> constructors = classDescriptor.getConstructors();
|
||||
Collection<ClassConstructorDescriptor> constructors = classDescriptor.getConstructors();
|
||||
if (constructors.isEmpty()) {
|
||||
context.trace.report(NO_CONSTRUCTOR.on(CallUtilKt.getValueArgumentListOrElement(context.call)));
|
||||
return checkArgumentTypesAndFail(context);
|
||||
}
|
||||
|
||||
Pair<Collection<ResolutionCandidate<ConstructorDescriptor>>, BasicCallResolutionContext> candidatesAndContext =
|
||||
Pair<Collection<ResolutionCandidate<ClassConstructorDescriptor>>, BasicCallResolutionContext> candidatesAndContext =
|
||||
prepareCandidatesAndContextForConstructorCall(constructedType, context);
|
||||
|
||||
Collection<ResolutionCandidate<ConstructorDescriptor>> candidates = candidatesAndContext.getFirst();
|
||||
Collection<ResolutionCandidate<ClassConstructorDescriptor>> candidates = candidatesAndContext.getFirst();
|
||||
context = candidatesAndContext.getSecond();
|
||||
|
||||
return computeTasksFromCandidatesAndResolvedCall(context, functionReference, candidates);
|
||||
}
|
||||
|
||||
@Nullable
|
||||
public OverloadResolutionResults<ConstructorDescriptor> resolveConstructorDelegationCall(
|
||||
public OverloadResolutionResults<ClassConstructorDescriptor> resolveConstructorDelegationCall(
|
||||
@NotNull BindingTrace trace, @NotNull LexicalScope scope, @NotNull DataFlowInfo dataFlowInfo,
|
||||
@NotNull ConstructorDescriptor constructorDescriptor,
|
||||
@NotNull ClassConstructorDescriptor constructorDescriptor,
|
||||
@NotNull KtConstructorDelegationCall call
|
||||
) {
|
||||
// Method returns `null` when there is nothing to resolve in trivial cases like `null` call expression or
|
||||
@@ -368,7 +368,7 @@ public class CallResolver {
|
||||
|
||||
if (call.getCalleeExpression() == null) return checkArgumentTypesAndFail(context);
|
||||
|
||||
if (constructorDescriptor.getContainingDeclaration().getKind() == ClassKind.ENUM_CLASS && call.isImplicit()) {
|
||||
if (constructorDescriptor.getConstructedClass().getKind() == ClassKind.ENUM_CLASS && call.isImplicit()) {
|
||||
return null;
|
||||
}
|
||||
|
||||
@@ -381,11 +381,11 @@ public class CallResolver {
|
||||
}
|
||||
|
||||
@NotNull
|
||||
private OverloadResolutionResults<ConstructorDescriptor> resolveConstructorDelegationCall(
|
||||
private OverloadResolutionResults<ClassConstructorDescriptor> resolveConstructorDelegationCall(
|
||||
@NotNull BasicCallResolutionContext context,
|
||||
@NotNull KtConstructorDelegationCall call,
|
||||
@NotNull KtConstructorDelegationReferenceExpression calleeExpression,
|
||||
@NotNull ConstructorDescriptor calleeConstructor
|
||||
@NotNull ClassConstructorDescriptor calleeConstructor
|
||||
) {
|
||||
context.trace.record(BindingContext.LEXICAL_SCOPE, call, context.scope);
|
||||
|
||||
@@ -399,7 +399,7 @@ public class CallResolver {
|
||||
|
||||
ClassDescriptor delegateClassDescriptor = isThisCall ? currentClassDescriptor :
|
||||
DescriptorUtilsKt.getSuperClassOrAny(currentClassDescriptor);
|
||||
Collection<ConstructorDescriptor> constructors = delegateClassDescriptor.getConstructors();
|
||||
Collection<ClassConstructorDescriptor> constructors = delegateClassDescriptor.getConstructors();
|
||||
|
||||
if (!isThisCall && currentClassDescriptor.getUnsubstitutedPrimaryConstructor() != null) {
|
||||
if (DescriptorUtils.canHaveDeclaredConstructors(currentClassDescriptor)) {
|
||||
@@ -421,9 +421,9 @@ public class CallResolver {
|
||||
calleeConstructor.getContainingDeclaration().getDefaultType() :
|
||||
DescriptorUtils.getSuperClassType(currentClassDescriptor);
|
||||
|
||||
Pair<Collection<ResolutionCandidate<ConstructorDescriptor>>, BasicCallResolutionContext> candidatesAndContext =
|
||||
Pair<Collection<ResolutionCandidate<ClassConstructorDescriptor>>, BasicCallResolutionContext> candidatesAndContext =
|
||||
prepareCandidatesAndContextForConstructorCall(superType, context);
|
||||
Collection<ResolutionCandidate<ConstructorDescriptor>> candidates = candidatesAndContext.getFirst();
|
||||
Collection<ResolutionCandidate<ClassConstructorDescriptor>> candidates = candidatesAndContext.getFirst();
|
||||
context = candidatesAndContext.getSecond();
|
||||
|
||||
TracingStrategy tracing = call.isImplicit() ?
|
||||
@@ -442,13 +442,13 @@ public class CallResolver {
|
||||
}
|
||||
|
||||
@NotNull
|
||||
private static Pair<Collection<ResolutionCandidate<ConstructorDescriptor>>, BasicCallResolutionContext> prepareCandidatesAndContextForConstructorCall(
|
||||
private static Pair<Collection<ResolutionCandidate<ClassConstructorDescriptor>>, BasicCallResolutionContext> prepareCandidatesAndContextForConstructorCall(
|
||||
@NotNull KotlinType superType,
|
||||
@NotNull BasicCallResolutionContext context
|
||||
) {
|
||||
if (!(superType.getConstructor().getDeclarationDescriptor() instanceof ClassDescriptor)) {
|
||||
return new Pair<Collection<ResolutionCandidate<ConstructorDescriptor>>, BasicCallResolutionContext>(
|
||||
Collections.<ResolutionCandidate<ConstructorDescriptor>>emptyList(), context);
|
||||
return new Pair<Collection<ResolutionCandidate<ClassConstructorDescriptor>>, BasicCallResolutionContext>(
|
||||
Collections.<ResolutionCandidate<ClassConstructorDescriptor>>emptyList(), context);
|
||||
}
|
||||
|
||||
ClassDescriptor superClass = (ClassDescriptor) superType.getConstructor().getDeclarationDescriptor();
|
||||
@@ -463,10 +463,10 @@ public class CallResolver {
|
||||
context = context.replaceExpectedType(superType);
|
||||
}
|
||||
|
||||
Collection<ResolutionCandidate<ConstructorDescriptor>> candidates =
|
||||
Collection<ResolutionCandidate<ClassConstructorDescriptor>> candidates =
|
||||
CallResolverUtilKt.createResolutionCandidatesForConstructors(context.scope, context.call, superClass, knownTypeParametersSubstitutor);
|
||||
|
||||
return new Pair<Collection<ResolutionCandidate<ConstructorDescriptor>>, BasicCallResolutionContext>(candidates, context);
|
||||
return new Pair<Collection<ResolutionCandidate<ClassConstructorDescriptor>>, BasicCallResolutionContext>(candidates, context);
|
||||
}
|
||||
|
||||
private static boolean anyConstructorHasDeclaredTypeParameters(@Nullable ClassifierDescriptor classDescriptor) {
|
||||
|
||||
@@ -202,7 +202,7 @@ fun createResolutionCandidatesForConstructors(
|
||||
call: Call,
|
||||
classWithConstructors: ClassDescriptor,
|
||||
knownSubstitutor: TypeSubstitutor? = null
|
||||
): Collection<ResolutionCandidate<ConstructorDescriptor>> {
|
||||
): Collection<ResolutionCandidate<ClassConstructorDescriptor>> {
|
||||
val constructors = classWithConstructors.constructors
|
||||
|
||||
if (constructors.isEmpty()) return emptyList()
|
||||
|
||||
@@ -240,7 +240,7 @@ class CandidateResolver(
|
||||
val dispatchReceiver = candidateCall.dispatchReceiver
|
||||
if (dispatchReceiver != null) {
|
||||
var nestedClass: ClassDescriptor? = null
|
||||
if (candidateDescriptor is ConstructorDescriptor
|
||||
if (candidateDescriptor is ClassConstructorDescriptor
|
||||
&& DescriptorUtils.isStaticNestedClass(candidateDescriptor.containingDeclaration)
|
||||
) {
|
||||
nestedClass = candidateDescriptor.containingDeclaration
|
||||
@@ -285,7 +285,7 @@ class CandidateResolver(
|
||||
if (expression is KtSimpleNameExpression) {
|
||||
// 'B' in 'class A: B()' is JetConstructorCalleeExpression
|
||||
if (descriptor is ConstructorDescriptor) {
|
||||
val modality = descriptor.containingDeclaration.modality
|
||||
val modality = descriptor.constructedClass.modality
|
||||
if (modality == Modality.ABSTRACT) {
|
||||
tracing.instantiationOfAbstractClass(trace)
|
||||
}
|
||||
|
||||
+2
-1
@@ -17,6 +17,7 @@
|
||||
package org.jetbrains.kotlin.resolve.calls.checkers
|
||||
|
||||
import com.intellij.psi.PsiElement
|
||||
import org.jetbrains.kotlin.descriptors.ClassConstructorDescriptor
|
||||
import org.jetbrains.kotlin.descriptors.ClassDescriptor
|
||||
import org.jetbrains.kotlin.descriptors.ConstructorDescriptor
|
||||
import org.jetbrains.kotlin.diagnostics.Errors
|
||||
@@ -47,7 +48,7 @@ object ConstructorHeaderCallChecker : CallChecker {
|
||||
|
||||
if (context.scope.parentsWithSelf.any { scope ->
|
||||
scope is LexicalScope && scope.kind == LexicalScopeKind.CONSTRUCTOR_HEADER &&
|
||||
(scope.ownerDescriptor as ConstructorDescriptor).containingDeclaration in classes
|
||||
(scope.ownerDescriptor as ClassConstructorDescriptor).containingDeclaration in classes
|
||||
}) {
|
||||
context.trace.report(Errors.INSTANCE_ACCESS_BEFORE_SUPER_CALL.on(reportOn, resolvedCall.resultingDescriptor))
|
||||
}
|
||||
|
||||
+1
-1
@@ -625,7 +625,7 @@ private class ConstantExpressionEvaluatorVisitor(
|
||||
|
||||
// Ann()
|
||||
if (resultingDescriptor is ConstructorDescriptor) {
|
||||
val classDescriptor: ClassDescriptor = resultingDescriptor.containingDeclaration
|
||||
val classDescriptor: ClassDescriptor = resultingDescriptor.constructedClass
|
||||
if (DescriptorUtils.isAnnotationClass(classDescriptor)) {
|
||||
val descriptor = AnnotationDescriptorImpl(
|
||||
classDescriptor.defaultType,
|
||||
|
||||
@@ -160,7 +160,7 @@ public class InlineUtil {
|
||||
public static boolean isArrayConstructorWithLambda(@NotNull CallableDescriptor descriptor) {
|
||||
return descriptor.getValueParameters().size() == 2 &&
|
||||
descriptor instanceof ConstructorDescriptor &&
|
||||
KotlinBuiltIns.isArrayOrPrimitiveArray(((ConstructorDescriptor) descriptor).getContainingDeclaration());
|
||||
KotlinBuiltIns.isArrayOrPrimitiveArray(((ConstructorDescriptor) descriptor).getConstructedClass());
|
||||
}
|
||||
|
||||
@Nullable
|
||||
|
||||
+2
-2
@@ -376,12 +376,12 @@ public class LazyClassDescriptor extends ClassDescriptorBase implements ClassDes
|
||||
|
||||
@NotNull
|
||||
@Override
|
||||
public Collection<ConstructorDescriptor> getConstructors() {
|
||||
public Collection<ClassConstructorDescriptor> getConstructors() {
|
||||
return unsubstitutedMemberScope.getConstructors();
|
||||
}
|
||||
|
||||
@Override
|
||||
public ConstructorDescriptor getUnsubstitutedPrimaryConstructor() {
|
||||
public ClassConstructorDescriptor getUnsubstitutedPrimaryConstructor() {
|
||||
return unsubstitutedMemberScope.getPrimaryConstructor();
|
||||
}
|
||||
|
||||
|
||||
+8
-8
@@ -20,7 +20,7 @@ import org.jetbrains.kotlin.builtins.KotlinBuiltIns
|
||||
import org.jetbrains.kotlin.descriptors.*
|
||||
import org.jetbrains.kotlin.descriptors.CallableMemberDescriptor.Kind.DELEGATION
|
||||
import org.jetbrains.kotlin.descriptors.CallableMemberDescriptor.Kind.FAKE_OVERRIDE
|
||||
import org.jetbrains.kotlin.descriptors.impl.ConstructorDescriptorImpl
|
||||
import org.jetbrains.kotlin.descriptors.impl.ClassConstructorDescriptorImpl
|
||||
import org.jetbrains.kotlin.diagnostics.DiagnosticSink
|
||||
import org.jetbrains.kotlin.diagnostics.Errors
|
||||
import org.jetbrains.kotlin.incremental.components.LookupLocation
|
||||
@@ -88,7 +88,7 @@ open class LazyClassMemberScope(
|
||||
fun extract(extractFrom: KotlinType, name: Name): Collection<T>
|
||||
}
|
||||
|
||||
private val primaryConstructor: NullableLazyValue<ConstructorDescriptor>
|
||||
private val primaryConstructor: NullableLazyValue<ClassConstructorDescriptor>
|
||||
= c.storageManager.createNullableLazyValue { resolvePrimaryConstructor() }
|
||||
|
||||
override fun getScopeForMemberDeclarationResolution(declaration: KtDeclaration): LexicalScope {
|
||||
@@ -292,18 +292,18 @@ open class LazyClassMemberScope(
|
||||
result.addAll(getContributedFunctions(Name.identifier("copy"), location))
|
||||
}
|
||||
|
||||
private val secondaryConstructors: NotNullLazyValue<Collection<ConstructorDescriptor>>
|
||||
private val secondaryConstructors: NotNullLazyValue<Collection<ClassConstructorDescriptor>>
|
||||
= c.storageManager.createLazyValue { resolveSecondaryConstructors() }
|
||||
|
||||
fun getConstructors(): Collection<ConstructorDescriptor> {
|
||||
fun getConstructors(): Collection<ClassConstructorDescriptor> {
|
||||
val result = secondaryConstructors()
|
||||
val primaryConstructor = getPrimaryConstructor()
|
||||
return if (primaryConstructor == null) result else result + primaryConstructor
|
||||
}
|
||||
|
||||
fun getPrimaryConstructor(): ConstructorDescriptor? = primaryConstructor()
|
||||
fun getPrimaryConstructor(): ClassConstructorDescriptor? = primaryConstructor()
|
||||
|
||||
protected open fun resolvePrimaryConstructor(): ConstructorDescriptor? {
|
||||
protected open fun resolvePrimaryConstructor(): ClassConstructorDescriptor? {
|
||||
val ownerInfo = declarationProvider.getOwnerInfo()
|
||||
val classOrObject = ownerInfo.correspondingClassOrObject ?: return null
|
||||
|
||||
@@ -324,7 +324,7 @@ open class LazyClassMemberScope(
|
||||
}
|
||||
}
|
||||
|
||||
private fun resolveSecondaryConstructors(): Collection<ConstructorDescriptor> {
|
||||
private fun resolveSecondaryConstructors(): Collection<ClassConstructorDescriptor> {
|
||||
val classOrObject = declarationProvider.getOwnerInfo().correspondingClassOrObject ?: return emptyList()
|
||||
|
||||
return classOrObject.getSecondaryConstructors().map { constructor ->
|
||||
@@ -336,7 +336,7 @@ open class LazyClassMemberScope(
|
||||
}
|
||||
}
|
||||
|
||||
protected fun setDeferredReturnType(descriptor: ConstructorDescriptorImpl) {
|
||||
protected fun setDeferredReturnType(descriptor: ClassConstructorDescriptorImpl) {
|
||||
descriptor.returnType = DeferredType.create(c.storageManager, trace, { thisDescriptor.getDefaultType() })
|
||||
}
|
||||
|
||||
|
||||
+4
-4
@@ -18,7 +18,7 @@ package org.jetbrains.kotlin.resolve.lazy.descriptors
|
||||
|
||||
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.PropertyDescriptorImpl
|
||||
import org.jetbrains.kotlin.descriptors.impl.ValueParameterDescriptorImpl
|
||||
import org.jetbrains.kotlin.incremental.components.LookupLocation
|
||||
@@ -37,8 +37,8 @@ class LazyScriptClassMemberScope(
|
||||
trace: BindingTrace)
|
||||
: LazyClassMemberScope(resolveSession, declarationProvider, scriptDescriptor, trace) {
|
||||
|
||||
override fun resolvePrimaryConstructor(): ConstructorDescriptor? {
|
||||
val constructor = ConstructorDescriptorImpl.create(
|
||||
override fun resolvePrimaryConstructor(): ClassConstructorDescriptor? {
|
||||
val constructor = ClassConstructorDescriptorImpl.create(
|
||||
scriptDescriptor,
|
||||
Annotations.EMPTY,
|
||||
true,
|
||||
@@ -52,7 +52,7 @@ class LazyScriptClassMemberScope(
|
||||
return constructor
|
||||
}
|
||||
|
||||
private fun createScriptParameters(constructor: ConstructorDescriptorImpl): List<ValueParameterDescriptor> {
|
||||
private fun createScriptParameters(constructor: ClassConstructorDescriptorImpl): List<ValueParameterDescriptor> {
|
||||
return scriptDescriptor.scriptDefinition.getScriptParameters(scriptDescriptor).mapIndexed { index, scriptParameter ->
|
||||
ValueParameterDescriptorImpl(
|
||||
constructor, null, index, Annotations.EMPTY, scriptParameter.name, scriptParameter.type,
|
||||
|
||||
@@ -6,11 +6,11 @@ typealias <!REDECLARATION!>SomeClass<!> = Any
|
||||
typealias <!REDECLARATION!>SomeClass<!> = Any
|
||||
|
||||
class Outer {
|
||||
class <!REDECLARATION, CONFLICTING_OVERLOADS!>Nested<!>
|
||||
class <!REDECLARATION!>Nested<!>
|
||||
|
||||
<!CONFLICTING_OVERLOADS!>typealias <!REDECLARATION!>Nested<!> = Any<!>
|
||||
<!CONFLICTING_OVERLOADS!>typealias <!REDECLARATION!>Nested<!> = Any<!>
|
||||
<!CONFLICTING_OVERLOADS!>typealias <!REDECLARATION!>Nested<!> = Any<!>
|
||||
typealias <!REDECLARATION!>Nested<!> = Any
|
||||
typealias <!REDECLARATION!>Nested<!> = Any
|
||||
typealias <!REDECLARATION!>Nested<!> = Any
|
||||
}
|
||||
|
||||
// FILE: file2.kt
|
||||
|
||||
@@ -3,5 +3,5 @@
|
||||
typealias Exn = java.lang.Exception
|
||||
|
||||
fun test() {
|
||||
throw <!FUNCTION_CALL_EXPECTED!>Exn<!>
|
||||
throw <!NO_COMPANION_OBJECT!>Exn<!>
|
||||
}
|
||||
+6
-6
@@ -1,13 +1,13 @@
|
||||
<set-?>:ValueParameterDescriptor
|
||||
Class.<get-classProp>:PropertyGetterDescriptor
|
||||
Class.<init>():ConstructorDescriptor
|
||||
Class.<init>():ClassConstructorDescriptor
|
||||
Class.classFunc:SimpleFunctionDescriptor
|
||||
Class.classProp:PropertyDescriptor
|
||||
Class.this:ReceiverParameterDescriptor
|
||||
Class:ClassDescriptorWithResolutionScopes
|
||||
Companion.<get-classObjProp>:PropertyGetterDescriptor
|
||||
Companion.<init>():ConstructorDescriptor
|
||||
Companion.<init>():ConstructorDescriptor
|
||||
Companion.<init>():ClassConstructorDescriptor
|
||||
Companion.<init>():ClassConstructorDescriptor
|
||||
Companion.classObjFunc:SimpleFunctionDescriptor
|
||||
Companion.classObjProp:PropertyDescriptor
|
||||
Companion.nestedClassObjFunc:SimpleFunctionDescriptor
|
||||
@@ -15,10 +15,10 @@ Companion.this:ReceiverParameterDescriptor
|
||||
Companion.this:ReceiverParameterDescriptor
|
||||
Companion:ClassDescriptorWithResolutionScopes
|
||||
Companion:ClassDescriptorWithResolutionScopes
|
||||
NestedClass.<init>():ConstructorDescriptor
|
||||
NestedClass.<init>():ClassConstructorDescriptor
|
||||
NestedClass.this:ReceiverParameterDescriptor
|
||||
NestedClass:ClassDescriptorWithResolutionScopes
|
||||
NestedObject.<init>():ConstructorDescriptor
|
||||
NestedObject.<init>():ClassConstructorDescriptor
|
||||
NestedObject.nestedFunc:SimpleFunctionDescriptor
|
||||
NestedObject.this:ReceiverParameterDescriptor
|
||||
NestedObject:ClassDescriptorWithResolutionScopes
|
||||
@@ -26,7 +26,7 @@ NestedTrait.nestedTraitFun:SimpleFunctionDescriptor
|
||||
NestedTrait.this:ReceiverParameterDescriptor
|
||||
NestedTrait:ClassDescriptorWithResolutionScopes
|
||||
Object.<get-objProp>:PropertyGetterDescriptor
|
||||
Object.<init>():ConstructorDescriptor
|
||||
Object.<init>():ClassConstructorDescriptor
|
||||
Object.objFunc:SimpleFunctionDescriptor
|
||||
Object.objProp:PropertyDescriptor
|
||||
Object.this:ReceiverParameterDescriptor
|
||||
|
||||
+1
-1
@@ -115,7 +115,7 @@ abstract class AbstractJvmRuntimeDescriptorLoaderTest : TestCaseWithTmpdir() {
|
||||
}
|
||||
|
||||
private fun DeclarationDescriptor.isJavaAnnotationConstructor() =
|
||||
this is ConstructorDescriptor &&
|
||||
this is ClassConstructorDescriptor &&
|
||||
containingDeclaration is JavaClassDescriptor &&
|
||||
containingDeclaration.kind == ClassKind.ANNOTATION_CLASS
|
||||
|
||||
|
||||
+1
-1
@@ -317,7 +317,7 @@ public abstract class AbstractAnnotationDescriptorResolveTest extends KotlinTest
|
||||
|
||||
@NotNull
|
||||
private static ConstructorDescriptor getConstructorDescriptor(@NotNull ClassDescriptor classDescriptor) {
|
||||
Collection<ConstructorDescriptor> constructors = classDescriptor.getConstructors();
|
||||
Collection<ClassConstructorDescriptor> constructors = classDescriptor.getConstructors();
|
||||
assert constructors.size() == 1;
|
||||
return constructors.iterator().next();
|
||||
}
|
||||
|
||||
+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
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
+1
-1
@@ -93,7 +93,7 @@ class FunctionClassDescriptor(
|
||||
override fun getUnsubstitutedMemberScope() = memberScope
|
||||
|
||||
override fun getCompanionObjectDescriptor() = null
|
||||
override fun getConstructors() = emptyList<ConstructorDescriptor>()
|
||||
override fun getConstructors() = emptyList<ClassConstructorDescriptor>()
|
||||
override fun getKind() = ClassKind.INTERFACE
|
||||
override fun getModality() = Modality.ABSTRACT
|
||||
override fun getUnsubstitutedPrimaryConstructor() = null
|
||||
|
||||
@@ -0,0 +1,36 @@
|
||||
/*
|
||||
* Copyright 2010-2016 JetBrains s.r.o.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
package org.jetbrains.kotlin.descriptors
|
||||
|
||||
import org.jetbrains.kotlin.types.TypeSubstitutor
|
||||
|
||||
|
||||
interface ClassConstructorDescriptor : ConstructorDescriptor {
|
||||
override fun getContainingDeclaration(): ClassDescriptor
|
||||
|
||||
override fun getOriginal(): ClassConstructorDescriptor
|
||||
|
||||
override fun substitute(substitutor: TypeSubstitutor): ClassConstructorDescriptor
|
||||
|
||||
override fun copy(
|
||||
newOwner: DeclarationDescriptor,
|
||||
modality: Modality,
|
||||
visibility: Visibility,
|
||||
kind: CallableMemberDescriptor.Kind,
|
||||
copyOverrides: Boolean
|
||||
): ClassConstructorDescriptor
|
||||
}
|
||||
@@ -46,7 +46,7 @@ public interface ClassDescriptor extends ClassifierDescriptorWithTypeParameters,
|
||||
|
||||
@NotNull
|
||||
@ReadOnly
|
||||
Collection<ConstructorDescriptor> getConstructors();
|
||||
Collection<ClassConstructorDescriptor> getConstructors();
|
||||
|
||||
@Override
|
||||
@NotNull
|
||||
@@ -88,7 +88,7 @@ public interface ClassDescriptor extends ClassifierDescriptorWithTypeParameters,
|
||||
ReceiverParameterDescriptor getThisAsReceiverParameter();
|
||||
|
||||
@Nullable
|
||||
ConstructorDescriptor getUnsubstitutedPrimaryConstructor();
|
||||
ClassConstructorDescriptor getUnsubstitutedPrimaryConstructor();
|
||||
|
||||
/**
|
||||
* It may differ from 'typeConstructor.parameters' in current class is inner, 'typeConstructor.parameters' contains
|
||||
|
||||
+1
-1
@@ -21,7 +21,7 @@ import org.jetbrains.annotations.ReadOnly;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
public interface ClassifierDescriptorWithTypeParameters extends ClassifierDescriptor {
|
||||
public interface ClassifierDescriptorWithTypeParameters extends ClassifierDescriptor, DeclarationDescriptorWithVisibility {
|
||||
/**
|
||||
* @return <code>true</code> if this class contains a reference to its outer class (as opposed to static nested class)
|
||||
*/
|
||||
|
||||
@@ -34,7 +34,10 @@ public interface ConstructorDescriptor extends FunctionDescriptor {
|
||||
|
||||
@NotNull
|
||||
@Override
|
||||
ClassDescriptor getContainingDeclaration();
|
||||
ClassifierDescriptorWithTypeParameters getContainingDeclaration();
|
||||
|
||||
@NotNull
|
||||
ClassDescriptor getConstructedClass();
|
||||
|
||||
@NotNull
|
||||
@Override
|
||||
|
||||
@@ -28,7 +28,7 @@ public interface ScriptDescriptor extends ClassDescriptor {
|
||||
|
||||
@NotNull
|
||||
@Override
|
||||
ConstructorDescriptor getUnsubstitutedPrimaryConstructor();
|
||||
ClassConstructorDescriptor getUnsubstitutedPrimaryConstructor();
|
||||
|
||||
List<Pair<Name, KotlinType>> getScriptParametersToPassToSuperclass();
|
||||
}
|
||||
|
||||
@@ -52,7 +52,7 @@ public class Visibilities {
|
||||
}
|
||||
|
||||
if (what instanceof ConstructorDescriptor) {
|
||||
ClassDescriptor classDescriptor = ((ConstructorDescriptor) what).getContainingDeclaration();
|
||||
ClassifierDescriptorWithTypeParameters classDescriptor = ((ConstructorDescriptor) what).getContainingDeclaration();
|
||||
if (DescriptorUtils.isSealedClass(classDescriptor)
|
||||
&& DescriptorUtils.isTopLevelDeclaration(classDescriptor)
|
||||
&& from instanceof ConstructorDescriptor
|
||||
|
||||
+20
-14
@@ -27,13 +27,13 @@ import java.util.Collection;
|
||||
import java.util.Collections;
|
||||
import java.util.List;
|
||||
|
||||
public class ConstructorDescriptorImpl extends FunctionDescriptorImpl implements ConstructorDescriptor {
|
||||
public class ClassConstructorDescriptorImpl extends FunctionDescriptorImpl implements ClassConstructorDescriptor {
|
||||
|
||||
protected final boolean isPrimary;
|
||||
|
||||
private static final Name NAME = Name.special("<init>");
|
||||
|
||||
protected ConstructorDescriptorImpl(
|
||||
protected ClassConstructorDescriptorImpl(
|
||||
@NotNull ClassDescriptor containingDeclaration,
|
||||
@Nullable ConstructorDescriptor original,
|
||||
@NotNull Annotations annotations,
|
||||
@@ -46,16 +46,16 @@ public class ConstructorDescriptorImpl extends FunctionDescriptorImpl implements
|
||||
}
|
||||
|
||||
@NotNull
|
||||
public static ConstructorDescriptorImpl create(
|
||||
public static ClassConstructorDescriptorImpl create(
|
||||
@NotNull ClassDescriptor containingDeclaration,
|
||||
@NotNull Annotations annotations,
|
||||
boolean isPrimary,
|
||||
@NotNull SourceElement source
|
||||
) {
|
||||
return new ConstructorDescriptorImpl(containingDeclaration, null, annotations, isPrimary, Kind.DECLARATION, source);
|
||||
return new ClassConstructorDescriptorImpl(containingDeclaration, null, annotations, isPrimary, Kind.DECLARATION, source);
|
||||
}
|
||||
|
||||
public ConstructorDescriptorImpl initialize(
|
||||
public ClassConstructorDescriptorImpl initialize(
|
||||
@NotNull List<ValueParameterDescriptor> unsubstitutedValueParameters,
|
||||
@NotNull Visibility visibility,
|
||||
@NotNull List<TypeParameterDescriptor> typeParameterDescriptors
|
||||
@@ -68,7 +68,7 @@ public class ConstructorDescriptorImpl extends FunctionDescriptorImpl implements
|
||||
return this;
|
||||
}
|
||||
|
||||
public ConstructorDescriptorImpl initialize(
|
||||
public ClassConstructorDescriptorImpl initialize(
|
||||
@NotNull List<ValueParameterDescriptor> unsubstitutedValueParameters,
|
||||
@NotNull Visibility visibility
|
||||
) {
|
||||
@@ -96,14 +96,20 @@ public class ConstructorDescriptorImpl extends FunctionDescriptorImpl implements
|
||||
|
||||
@NotNull
|
||||
@Override
|
||||
public ConstructorDescriptor getOriginal() {
|
||||
return (ConstructorDescriptor) super.getOriginal();
|
||||
public ClassDescriptor getConstructedClass() {
|
||||
return getContainingDeclaration();
|
||||
}
|
||||
|
||||
@NotNull
|
||||
@Override
|
||||
public ConstructorDescriptor substitute(@NotNull TypeSubstitutor originalSubstitutor) {
|
||||
return (ConstructorDescriptor) super.substitute(originalSubstitutor);
|
||||
public ClassConstructorDescriptor getOriginal() {
|
||||
return (ClassConstructorDescriptor) super.getOriginal();
|
||||
}
|
||||
|
||||
@NotNull
|
||||
@Override
|
||||
public ClassConstructorDescriptor substitute(@NotNull TypeSubstitutor originalSubstitutor) {
|
||||
return (ClassConstructorDescriptor) super.substitute(originalSubstitutor);
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -129,7 +135,7 @@ public class ConstructorDescriptorImpl extends FunctionDescriptorImpl implements
|
||||
|
||||
@NotNull
|
||||
@Override
|
||||
protected ConstructorDescriptorImpl createSubstitutedCopy(
|
||||
protected ClassConstructorDescriptorImpl createSubstitutedCopy(
|
||||
@NotNull DeclarationDescriptor newOwner,
|
||||
@Nullable FunctionDescriptor original,
|
||||
@NotNull Kind kind,
|
||||
@@ -144,7 +150,7 @@ public class ConstructorDescriptorImpl extends FunctionDescriptorImpl implements
|
||||
"kind: " + kind);
|
||||
}
|
||||
assert newName == null : "Attempt to rename constructor: " + this;
|
||||
return new ConstructorDescriptorImpl(
|
||||
return new ClassConstructorDescriptorImpl(
|
||||
(ClassDescriptor) newOwner,
|
||||
this,
|
||||
annotations,
|
||||
@@ -156,13 +162,13 @@ public class ConstructorDescriptorImpl extends FunctionDescriptorImpl implements
|
||||
|
||||
@NotNull
|
||||
@Override
|
||||
public ConstructorDescriptor copy(
|
||||
public ClassConstructorDescriptor copy(
|
||||
DeclarationDescriptor newOwner,
|
||||
Modality modality,
|
||||
Visibility visibility,
|
||||
Kind kind,
|
||||
boolean copyOverrides
|
||||
) {
|
||||
return (ConstructorDescriptor) super.copy(newOwner, modality, visibility, kind, copyOverrides);
|
||||
return (ClassConstructorDescriptor) super.copy(newOwner, modality, visibility, kind, copyOverrides);
|
||||
}
|
||||
}
|
||||
@@ -38,8 +38,8 @@ public class ClassDescriptorImpl extends ClassDescriptorBase {
|
||||
private final TypeConstructor typeConstructor;
|
||||
|
||||
private MemberScope unsubstitutedMemberScope;
|
||||
private Set<ConstructorDescriptor> constructors;
|
||||
private ConstructorDescriptor primaryConstructor;
|
||||
private Set<ClassConstructorDescriptor> constructors;
|
||||
private ClassConstructorDescriptor primaryConstructor;
|
||||
|
||||
public ClassDescriptorImpl(
|
||||
@NotNull DeclarationDescriptor containingDeclaration,
|
||||
@@ -60,8 +60,8 @@ public class ClassDescriptorImpl extends ClassDescriptorBase {
|
||||
|
||||
public final void initialize(
|
||||
@NotNull MemberScope unsubstitutedMemberScope,
|
||||
@NotNull Set<ConstructorDescriptor> constructors,
|
||||
@Nullable ConstructorDescriptor primaryConstructor
|
||||
@NotNull Set<ClassConstructorDescriptor> constructors,
|
||||
@Nullable ClassConstructorDescriptor primaryConstructor
|
||||
) {
|
||||
this.unsubstitutedMemberScope = unsubstitutedMemberScope;
|
||||
this.constructors = constructors;
|
||||
@@ -82,7 +82,7 @@ public class ClassDescriptorImpl extends ClassDescriptorBase {
|
||||
|
||||
@NotNull
|
||||
@Override
|
||||
public Collection<ConstructorDescriptor> getConstructors() {
|
||||
public Collection<ClassConstructorDescriptor> getConstructors() {
|
||||
return constructors;
|
||||
}
|
||||
|
||||
@@ -116,7 +116,7 @@ public class ClassDescriptorImpl extends ClassDescriptorBase {
|
||||
}
|
||||
|
||||
@Override
|
||||
public ConstructorDescriptor getUnsubstitutedPrimaryConstructor() {
|
||||
public ClassConstructorDescriptor getUnsubstitutedPrimaryConstructor() {
|
||||
return primaryConstructor;
|
||||
}
|
||||
|
||||
|
||||
+4
-4
@@ -43,7 +43,7 @@ import java.util.*;
|
||||
|
||||
public class EnumEntrySyntheticClassDescriptor extends ClassDescriptorBase {
|
||||
private final TypeConstructor typeConstructor;
|
||||
private final ConstructorDescriptor primaryConstructor;
|
||||
private final ClassConstructorDescriptor primaryConstructor;
|
||||
private final MemberScope scope;
|
||||
private final NotNullLazyValue<Set<Name>> enumMemberNames;
|
||||
private final Annotations annotations;
|
||||
@@ -86,7 +86,7 @@ public class EnumEntrySyntheticClassDescriptor extends ClassDescriptorBase {
|
||||
this.scope = new EnumEntryScope(storageManager);
|
||||
this.enumMemberNames = enumMemberNames;
|
||||
|
||||
ConstructorDescriptorImpl primaryConstructor = DescriptorFactory.createPrimaryConstructorForObject(this, source);
|
||||
ClassConstructorDescriptorImpl primaryConstructor = DescriptorFactory.createPrimaryConstructorForObject(this, source);
|
||||
primaryConstructor.setReturnType(getDefaultType());
|
||||
this.primaryConstructor = primaryConstructor;
|
||||
}
|
||||
@@ -105,7 +105,7 @@ public class EnumEntrySyntheticClassDescriptor extends ClassDescriptorBase {
|
||||
|
||||
@NotNull
|
||||
@Override
|
||||
public Collection<ConstructorDescriptor> getConstructors() {
|
||||
public Collection<ClassConstructorDescriptor> getConstructors() {
|
||||
return Collections.singleton(primaryConstructor);
|
||||
}
|
||||
|
||||
@@ -156,7 +156,7 @@ public class EnumEntrySyntheticClassDescriptor extends ClassDescriptorBase {
|
||||
|
||||
@Nullable
|
||||
@Override
|
||||
public ConstructorDescriptor getUnsubstitutedPrimaryConstructor() {
|
||||
public ClassConstructorDescriptor getUnsubstitutedPrimaryConstructor() {
|
||||
return primaryConstructor;
|
||||
}
|
||||
|
||||
|
||||
+6
-6
@@ -143,11 +143,11 @@ public class LazySubstitutingClassDescriptor implements ClassDescriptor {
|
||||
|
||||
@NotNull
|
||||
@Override
|
||||
public Collection<ConstructorDescriptor> getConstructors() {
|
||||
Collection<ConstructorDescriptor> originalConstructors = original.getConstructors();
|
||||
Collection<ConstructorDescriptor> result = new ArrayList<ConstructorDescriptor>(originalConstructors.size());
|
||||
for (ConstructorDescriptor constructor : originalConstructors) {
|
||||
ConstructorDescriptor copy =
|
||||
public Collection<ClassConstructorDescriptor> getConstructors() {
|
||||
Collection<ClassConstructorDescriptor> originalConstructors = original.getConstructors();
|
||||
Collection<ClassConstructorDescriptor> result = new ArrayList<ClassConstructorDescriptor>(originalConstructors.size());
|
||||
for (ClassConstructorDescriptor constructor : originalConstructors) {
|
||||
ClassConstructorDescriptor copy =
|
||||
constructor.copy(this, constructor.getModality(), constructor.getVisibility(), constructor.getKind(), false);
|
||||
result.add(copy.substitute(getSubstitutor()));
|
||||
}
|
||||
@@ -241,7 +241,7 @@ public class LazySubstitutingClassDescriptor implements ClassDescriptor {
|
||||
|
||||
@Nullable
|
||||
@Override
|
||||
public ConstructorDescriptor getUnsubstitutedPrimaryConstructor() {
|
||||
public ClassConstructorDescriptor getUnsubstitutedPrimaryConstructor() {
|
||||
return original.getUnsubstitutedPrimaryConstructor();
|
||||
}
|
||||
|
||||
|
||||
+13
-6
@@ -24,8 +24,8 @@ import org.jetbrains.kotlin.types.KotlinType
|
||||
import org.jetbrains.kotlin.types.TypeSubstitutor
|
||||
import org.jetbrains.kotlin.types.Variance
|
||||
|
||||
interface TypeAliasConstructorDescriptor : FunctionDescriptor {
|
||||
val underlyingConstructorDescriptor: ConstructorDescriptor
|
||||
interface TypeAliasConstructorDescriptor : ConstructorDescriptor {
|
||||
val underlyingConstructorDescriptor: ClassConstructorDescriptor
|
||||
|
||||
override fun getContainingDeclaration(): TypeAliasDescriptor
|
||||
|
||||
@@ -46,7 +46,7 @@ interface TypeAliasConstructorDescriptor : FunctionDescriptor {
|
||||
|
||||
class TypeAliasConstructorDescriptorImpl private constructor(
|
||||
val typeAliasDescriptor: TypeAliasDescriptor,
|
||||
override val underlyingConstructorDescriptor: ConstructorDescriptor,
|
||||
override val underlyingConstructorDescriptor: ClassConstructorDescriptor,
|
||||
original: TypeAliasConstructorDescriptor?,
|
||||
annotations: Annotations,
|
||||
kind: Kind,
|
||||
@@ -54,9 +54,15 @@ class TypeAliasConstructorDescriptorImpl private constructor(
|
||||
) : TypeAliasConstructorDescriptor,
|
||||
FunctionDescriptorImpl(typeAliasDescriptor, original, annotations, Name.special("<init>"), kind, source)
|
||||
{
|
||||
override fun isPrimary(): Boolean =
|
||||
underlyingConstructorDescriptor.isPrimary
|
||||
|
||||
override fun getContainingDeclaration(): TypeAliasDescriptor =
|
||||
typeAliasDescriptor
|
||||
|
||||
override fun getConstructedClass(): ClassDescriptor =
|
||||
underlyingConstructorDescriptor.constructedClass
|
||||
|
||||
override fun getReturnType(): KotlinType =
|
||||
super.getReturnType()!!
|
||||
|
||||
@@ -103,7 +109,7 @@ class TypeAliasConstructorDescriptorImpl private constructor(
|
||||
companion object {
|
||||
fun create(
|
||||
typeAliasDescriptor: TypeAliasDescriptor,
|
||||
constructor: ConstructorDescriptor,
|
||||
constructor: ClassConstructorDescriptor,
|
||||
substitutor: TypeSubstitutor
|
||||
): TypeAliasConstructorDescriptor? {
|
||||
val typeAliasConstructor =
|
||||
@@ -117,9 +123,10 @@ class TypeAliasConstructorDescriptorImpl private constructor(
|
||||
val returnType = substitutor.substitute(constructor.returnType, Variance.INVARIANT)
|
||||
?: return null
|
||||
|
||||
val containingDeclaration = constructor.containingDeclaration as ClassDescriptor
|
||||
val dispatchReceiverParameter =
|
||||
if (constructor.containingDeclaration.isInner)
|
||||
constructor.containingDeclaration.thisAsReceiverParameter
|
||||
if (containingDeclaration.isInner)
|
||||
containingDeclaration.thisAsReceiverParameter
|
||||
else
|
||||
null
|
||||
|
||||
|
||||
@@ -32,8 +32,8 @@ import static org.jetbrains.kotlin.resolve.DescriptorUtils.getDefaultConstructor
|
||||
import static org.jetbrains.kotlin.resolve.descriptorUtil.DescriptorUtilsKt.getBuiltIns;
|
||||
|
||||
public class DescriptorFactory {
|
||||
private static class DefaultConstructorDescriptor extends ConstructorDescriptorImpl {
|
||||
public DefaultConstructorDescriptor(@NotNull ClassDescriptor containingClass, @NotNull SourceElement source) {
|
||||
private static class DefaultClassConstructorDescriptor extends ClassConstructorDescriptorImpl {
|
||||
public DefaultClassConstructorDescriptor(@NotNull ClassDescriptor containingClass, @NotNull SourceElement source) {
|
||||
super(containingClass, null, Annotations.Companion.getEMPTY(), true, Kind.DECLARATION, source);
|
||||
initialize(Collections.<ValueParameterDescriptor>emptyList(),
|
||||
getDefaultConstructorVisibility(containingClass));
|
||||
@@ -116,11 +116,11 @@ public class DescriptorFactory {
|
||||
}
|
||||
|
||||
@NotNull
|
||||
public static ConstructorDescriptorImpl createPrimaryConstructorForObject(
|
||||
public static ClassConstructorDescriptorImpl createPrimaryConstructorForObject(
|
||||
@NotNull ClassDescriptor containingClass,
|
||||
@NotNull SourceElement source
|
||||
) {
|
||||
return new DefaultConstructorDescriptor(containingClass, source);
|
||||
return new DefaultClassConstructorDescriptor(containingClass, source);
|
||||
}
|
||||
|
||||
@NotNull
|
||||
|
||||
@@ -41,7 +41,7 @@ fun ClassDescriptor.getClassObjectReferenceTarget(): ClassDescriptor = companion
|
||||
|
||||
fun DeclarationDescriptor.getImportableDescriptor(): DeclarationDescriptor {
|
||||
return when {
|
||||
this is TypeAliasConstructorDescriptor -> typeAliasDescriptor
|
||||
this is TypeAliasConstructorDescriptor -> containingDeclaration
|
||||
this is ConstructorDescriptor -> containingDeclaration
|
||||
this is PropertyAccessorDescriptor -> correspondingProperty
|
||||
else -> this
|
||||
@@ -137,7 +137,7 @@ fun ClassDescriptor.getSuperInterfaces(): List<ClassDescriptor> =
|
||||
else null
|
||||
}
|
||||
|
||||
val ClassDescriptor.secondaryConstructors: List<ConstructorDescriptor>
|
||||
val ClassDescriptor.secondaryConstructors: List<ClassConstructorDescriptor>
|
||||
get() = constructors.filterNot { it.isPrimary }
|
||||
|
||||
val DeclarationDescriptor.builtIns: KotlinBuiltIns
|
||||
|
||||
@@ -24,7 +24,7 @@ import org.jetbrains.kotlin.builtins.KotlinBuiltIns;
|
||||
import org.jetbrains.kotlin.descriptors.*;
|
||||
import org.jetbrains.kotlin.descriptors.annotations.Annotations;
|
||||
import org.jetbrains.kotlin.descriptors.impl.ClassDescriptorImpl;
|
||||
import org.jetbrains.kotlin.descriptors.impl.ConstructorDescriptorImpl;
|
||||
import org.jetbrains.kotlin.descriptors.impl.ClassConstructorDescriptorImpl;
|
||||
import org.jetbrains.kotlin.descriptors.impl.PropertyDescriptorImpl;
|
||||
import org.jetbrains.kotlin.descriptors.impl.TypeParameterDescriptorImpl;
|
||||
import org.jetbrains.kotlin.incremental.components.LookupLocation;
|
||||
@@ -304,7 +304,8 @@ public class ErrorUtils {
|
||||
super(getErrorModule(), Name.special(name == null ? "<ERROR CLASS>" : "<ERROR CLASS: " + name + ">"),
|
||||
Modality.OPEN, ClassKind.CLASS, Collections.<KotlinType>emptyList(), SourceElement.NO_SOURCE);
|
||||
|
||||
ConstructorDescriptorImpl errorConstructor = ConstructorDescriptorImpl.create(this, Annotations.Companion.getEMPTY(), true, SourceElement.NO_SOURCE);
|
||||
ClassConstructorDescriptorImpl
|
||||
errorConstructor = ClassConstructorDescriptorImpl.create(this, Annotations.Companion.getEMPTY(), true, SourceElement.NO_SOURCE);
|
||||
errorConstructor.initialize(Collections.<ValueParameterDescriptor>emptyList(),
|
||||
Visibilities.INTERNAL);
|
||||
MemberScope memberScope = createErrorScope(getName().asString());
|
||||
@@ -315,7 +316,7 @@ public class ErrorUtils {
|
||||
)
|
||||
);
|
||||
|
||||
initialize(memberScope, Collections.<ConstructorDescriptor>singleton(errorConstructor), errorConstructor);
|
||||
initialize(memberScope, Collections.<ClassConstructorDescriptor>singleton(errorConstructor), errorConstructor);
|
||||
}
|
||||
|
||||
@NotNull
|
||||
|
||||
+3
-2
@@ -16,6 +16,7 @@
|
||||
|
||||
package org.jetbrains.kotlin.serialization.deserialization
|
||||
|
||||
import org.jetbrains.kotlin.descriptors.ClassConstructorDescriptor
|
||||
import org.jetbrains.kotlin.descriptors.ConstructorDescriptor
|
||||
import org.jetbrains.kotlin.descriptors.SimpleFunctionDescriptor
|
||||
import org.jetbrains.kotlin.name.Name
|
||||
@@ -25,13 +26,13 @@ import org.jetbrains.kotlin.types.KotlinType
|
||||
interface AdditionalClassPartsProvider {
|
||||
fun getSupertypes(classDescriptor: DeserializedClassDescriptor): Collection<KotlinType>
|
||||
fun getFunctions(name: Name, classDescriptor: DeserializedClassDescriptor): Collection<SimpleFunctionDescriptor>
|
||||
fun getConstructors(classDescriptor: DeserializedClassDescriptor): Collection<ConstructorDescriptor>
|
||||
fun getConstructors(classDescriptor: DeserializedClassDescriptor): Collection<ClassConstructorDescriptor>
|
||||
fun getFunctionsNames(classDescriptor: DeserializedClassDescriptor): Collection<Name>
|
||||
|
||||
object None : AdditionalClassPartsProvider {
|
||||
override fun getSupertypes(classDescriptor: DeserializedClassDescriptor): Collection<KotlinType> = emptyList()
|
||||
override fun getFunctions(name: Name, classDescriptor: DeserializedClassDescriptor): Collection<SimpleFunctionDescriptor> = emptyList()
|
||||
override fun getFunctionsNames(classDescriptor: DeserializedClassDescriptor): Collection<Name> = emptyList()
|
||||
override fun getConstructors(classDescriptor: DeserializedClassDescriptor): Collection<ConstructorDescriptor> = emptyList()
|
||||
override fun getConstructors(classDescriptor: DeserializedClassDescriptor): Collection<ClassConstructorDescriptor> = emptyList()
|
||||
}
|
||||
}
|
||||
|
||||
+2
-2
@@ -197,9 +197,9 @@ class MemberDeserializer(private val c: DeserializationContext) {
|
||||
return (c.containingDeclaration as? ClassDescriptor)?.thisAsReceiverParameter
|
||||
}
|
||||
|
||||
fun loadConstructor(proto: ProtoBuf.Constructor, isPrimary: Boolean): ConstructorDescriptor {
|
||||
fun loadConstructor(proto: ProtoBuf.Constructor, isPrimary: Boolean): ClassConstructorDescriptor {
|
||||
val classDescriptor = c.containingDeclaration as ClassDescriptor
|
||||
val descriptor = DeserializedConstructorDescriptor(
|
||||
val descriptor = DeserializedClassConstructorDescriptor(
|
||||
classDescriptor, null, getAnnotations(proto, proto.flags, AnnotatedCallableKind.FUNCTION),
|
||||
isPrimary, CallableMemberDescriptor.Kind.DECLARATION, proto, c.nameResolver, c.typeTable, c.containerSource
|
||||
)
|
||||
|
||||
+2
-2
@@ -106,8 +106,8 @@ class NotFoundClasses(private val storageManager: StorageManager, private val mo
|
||||
|
||||
override fun getUnsubstitutedMemberScope() = MemberScope.Empty
|
||||
override fun getStaticScope() = MemberScope.Empty
|
||||
override fun getConstructors(): Collection<ConstructorDescriptor> = emptySet()
|
||||
override fun getUnsubstitutedPrimaryConstructor(): ConstructorDescriptor? = null
|
||||
override fun getConstructors(): Collection<ClassConstructorDescriptor> = emptySet()
|
||||
override fun getUnsubstitutedPrimaryConstructor(): ClassConstructorDescriptor? = null
|
||||
override fun getCompanionObjectDescriptor(): ClassDescriptor? = null
|
||||
|
||||
override fun toString() = "class $name (not found)"
|
||||
|
||||
+4
-4
@@ -101,7 +101,7 @@ class DeserializedClassDescriptor(
|
||||
|
||||
override fun isCompanionObject(): Boolean = Flags.CLASS_KIND.get(classProto.flags) == ProtoBuf.Class.Kind.COMPANION_OBJECT
|
||||
|
||||
private fun computePrimaryConstructor(): ConstructorDescriptor? {
|
||||
private fun computePrimaryConstructor(): ClassConstructorDescriptor? {
|
||||
if (kind.isSingleton) {
|
||||
return DescriptorFactory.createPrimaryConstructorForObject(this, SourceElement.NO_SOURCE).apply {
|
||||
returnType = getDefaultType()
|
||||
@@ -113,13 +113,13 @@ class DeserializedClassDescriptor(
|
||||
}
|
||||
}
|
||||
|
||||
override fun getUnsubstitutedPrimaryConstructor(): ConstructorDescriptor? = primaryConstructor()
|
||||
override fun getUnsubstitutedPrimaryConstructor(): ClassConstructorDescriptor? = primaryConstructor()
|
||||
|
||||
private fun computeConstructors(): Collection<ConstructorDescriptor> =
|
||||
private fun computeConstructors(): Collection<ClassConstructorDescriptor> =
|
||||
computeSecondaryConstructors() + unsubstitutedPrimaryConstructor.singletonOrEmptyList() +
|
||||
c.components.additionalClassPartsProvider.getConstructors(this)
|
||||
|
||||
private fun computeSecondaryConstructors(): List<ConstructorDescriptor> =
|
||||
private fun computeSecondaryConstructors(): List<ClassConstructorDescriptor> =
|
||||
classProto.constructorList.filter { Flags.IS_SECONDARY.get(it.flags) }.map {
|
||||
c.memberDeserializer.loadConstructor(it, false)
|
||||
}
|
||||
|
||||
+4
-4
@@ -103,7 +103,7 @@ class DeserializedPropertyDescriptor(
|
||||
}
|
||||
}
|
||||
|
||||
class DeserializedConstructorDescriptor(
|
||||
class DeserializedClassConstructorDescriptor(
|
||||
containingDeclaration: ClassDescriptor,
|
||||
original: ConstructorDescriptor?,
|
||||
annotations: Annotations,
|
||||
@@ -115,7 +115,7 @@ class DeserializedConstructorDescriptor(
|
||||
override val containerSource: SourceElement?,
|
||||
source: SourceElement? = null
|
||||
) : DeserializedCallableMemberDescriptor,
|
||||
ConstructorDescriptorImpl(containingDeclaration, original, annotations, isPrimary, kind, source ?: SourceElement.NO_SOURCE) {
|
||||
ClassConstructorDescriptorImpl(containingDeclaration, original, annotations, isPrimary, kind, source ?: SourceElement.NO_SOURCE) {
|
||||
|
||||
override fun createSubstitutedCopy(
|
||||
newOwner: DeclarationDescriptor,
|
||||
@@ -124,8 +124,8 @@ class DeserializedConstructorDescriptor(
|
||||
newName: Name?,
|
||||
annotations: Annotations,
|
||||
source: SourceElement
|
||||
): DeserializedConstructorDescriptor {
|
||||
return DeserializedConstructorDescriptor(
|
||||
): DeserializedClassConstructorDescriptor {
|
||||
return DeserializedClassConstructorDescriptor(
|
||||
newOwner as ClassDescriptor, original as ConstructorDescriptor?, annotations, isPrimary, kind,
|
||||
proto, nameResolver, typeTable, containerSource, source
|
||||
)
|
||||
|
||||
@@ -24,7 +24,7 @@ import org.jetbrains.kotlin.descriptors.PackageFragmentDescriptor
|
||||
import org.jetbrains.kotlin.descriptors.PropertyDescriptor
|
||||
import org.jetbrains.kotlin.descriptors.Visibilities
|
||||
import org.jetbrains.kotlin.load.java.JvmAbi
|
||||
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.sources.JavaSourceElement
|
||||
@@ -188,7 +188,7 @@ internal object RuntimeTypeMapper {
|
||||
|
||||
return JvmFunctionSignature.JavaMethod(method)
|
||||
}
|
||||
is JavaConstructorDescriptor -> {
|
||||
is JavaClassConstructorDescriptor -> {
|
||||
val constructor = ((function.source as? JavaSourceElement)?.javaElement as? ReflectJavaConstructor)?.member ?:
|
||||
throw KotlinReflectionInternalError("Incorrect resolution sequence for Java constructor $function")
|
||||
|
||||
|
||||
@@ -521,7 +521,7 @@ class ResolveElementCache(
|
||||
val trace = createDelegatingTrace(constructor)
|
||||
|
||||
val scope = resolveSession.declarationScopeProvider.getResolutionScopeForDeclaration(constructor)
|
||||
val constructorDescriptor = resolveSession.resolveToDescriptor(constructor) as ConstructorDescriptor
|
||||
val constructorDescriptor = resolveSession.resolveToDescriptor(constructor) as ClassConstructorDescriptor
|
||||
ForceResolveUtil.forceResolveAllContents(constructorDescriptor)
|
||||
|
||||
val bodyResolver = createBodyResolver(resolveSession, trace, file, statementFilter)
|
||||
@@ -610,7 +610,7 @@ class ResolveElementCache(
|
||||
|
||||
override fun getAnonymousInitializers(): MutableMap<KtAnonymousInitializer, ClassDescriptorWithResolutionScopes> = hashMapOf()
|
||||
|
||||
override fun getSecondaryConstructors(): MutableMap<KtSecondaryConstructor, ConstructorDescriptor> = hashMapOf()
|
||||
override fun getSecondaryConstructors(): MutableMap<KtSecondaryConstructor, ClassConstructorDescriptor> = hashMapOf()
|
||||
|
||||
override fun getProperties(): MutableMap<KtProperty, PropertyDescriptor> = hashMapOf()
|
||||
|
||||
|
||||
+2
-1
@@ -22,6 +22,7 @@ import com.intellij.codeInspection.ProblemHighlightType
|
||||
import com.intellij.codeInspection.ProblemsHolder
|
||||
import com.intellij.openapi.project.Project
|
||||
import com.intellij.psi.PsiElementVisitor
|
||||
import org.jetbrains.kotlin.descriptors.ClassConstructorDescriptor
|
||||
import org.jetbrains.kotlin.descriptors.ConstructorDescriptor
|
||||
import org.jetbrains.kotlin.descriptors.ValueParameterDescriptor
|
||||
import org.jetbrains.kotlin.idea.caches.resolve.analyzeFully
|
||||
@@ -46,7 +47,7 @@ class CanBePrimaryConstructorPropertyInspection : AbstractKotlinInspection() {
|
||||
// to prevent some exotic situations
|
||||
if (!assignedDescriptor.annotations.isEmpty() || !assigned.getAnnotationEntries().isEmpty()) return
|
||||
|
||||
val containingConstructor = assignedDescriptor.containingDeclaration as? ConstructorDescriptor ?: return
|
||||
val containingConstructor = assignedDescriptor.containingDeclaration as? ClassConstructorDescriptor ?: return
|
||||
if (containingConstructor.containingDeclaration.isData) return
|
||||
|
||||
val propertyTypeReference = property.typeReference
|
||||
|
||||
@@ -25,6 +25,7 @@ import com.intellij.psi.PsiReference
|
||||
import com.intellij.psi.PsiReferenceProvider
|
||||
import com.intellij.psi.search.LocalSearchScope
|
||||
import com.intellij.util.ProcessingContext
|
||||
import org.jetbrains.kotlin.descriptors.ClassConstructorDescriptor
|
||||
import org.jetbrains.kotlin.descriptors.ClassKind
|
||||
import org.jetbrains.kotlin.descriptors.ConstructorDescriptor
|
||||
import org.jetbrains.kotlin.descriptors.DeclarationDescriptor
|
||||
@@ -91,7 +92,7 @@ private fun KtExpression.getBundleNameByContext(): String? {
|
||||
|
||||
private fun KtAnnotationEntry.getPropertyKeyResolvedCall(): ResolvedCall<*>? {
|
||||
val resolvedCall = getResolvedCall(analyze(BodyResolveMode.PARTIAL)) ?: return null
|
||||
val klass = (resolvedCall.resultingDescriptor as? ConstructorDescriptor)?.containingDeclaration ?: return null
|
||||
val klass = (resolvedCall.resultingDescriptor as? ClassConstructorDescriptor)?.containingDeclaration ?: return null
|
||||
if (klass.kind != ClassKind.ANNOTATION_CLASS || klass.importableFqName != PROPERTY_KEY) return null
|
||||
return resolvedCall
|
||||
}
|
||||
|
||||
+2
-1
@@ -20,6 +20,7 @@ import com.google.dart.compiler.backend.js.ast.*
|
||||
import org.jetbrains.kotlin.builtins.functions.FunctionInvokeDescriptor
|
||||
import org.jetbrains.kotlin.builtins.isExtensionFunctionType
|
||||
import org.jetbrains.kotlin.descriptors.CallableDescriptor
|
||||
import org.jetbrains.kotlin.descriptors.ClassConstructorDescriptor
|
||||
import org.jetbrains.kotlin.descriptors.ConstructorDescriptor
|
||||
import org.jetbrains.kotlin.descriptors.Visibilities
|
||||
import org.jetbrains.kotlin.js.PredefinedAnnotation
|
||||
@@ -225,7 +226,7 @@ object ConstructorCallCase : FunctionCallCase() {
|
||||
|
||||
val invocationArguments = mutableListOf<JsExpression>()
|
||||
|
||||
val constructorDescriptor = callableDescriptor as ConstructorDescriptor
|
||||
val constructorDescriptor = callableDescriptor as ClassConstructorDescriptor
|
||||
if (context.shouldBeDeferred(constructorDescriptor)) {
|
||||
context.deferConstructorCall(constructorDescriptor, invocationArguments)
|
||||
}
|
||||
|
||||
+2
-2
@@ -537,12 +537,12 @@ public class TranslationContext {
|
||||
return result;
|
||||
}
|
||||
|
||||
public boolean shouldBeDeferred(@NotNull ConstructorDescriptor constructor) {
|
||||
public boolean shouldBeDeferred(@NotNull ClassConstructorDescriptor constructor) {
|
||||
ClassDescriptor classDescriptor = constructor.getContainingDeclaration();
|
||||
return staticContext.getDeferredCallSites().containsKey(classDescriptor);
|
||||
}
|
||||
|
||||
public void deferConstructorCall(@NotNull ConstructorDescriptor constructor, @NotNull List<JsExpression> invocationArgs) {
|
||||
public void deferConstructorCall(@NotNull ClassConstructorDescriptor constructor, @NotNull List<JsExpression> invocationArgs) {
|
||||
ClassDescriptor classDescriptor = constructor.getContainingDeclaration();
|
||||
List<DeferredCallSite> callSites = staticContext.getDeferredCallSites().get(classDescriptor);
|
||||
if (callSites == null) throw new IllegalStateException("This method should be call only when `shouldBeDeferred` method " +
|
||||
|
||||
+3
-2
@@ -155,7 +155,8 @@ class ClassTranslator private constructor(
|
||||
|
||||
private fun generateSecondaryConstructor(classContext: TranslationContext, constructor: KtSecondaryConstructor) {
|
||||
// Prepare
|
||||
val constructorDescriptor = BindingUtils.getDescriptorForElement(classContext.bindingContext(), constructor) as ConstructorDescriptor
|
||||
val constructorDescriptor = BindingUtils.getDescriptorForElement(classContext.bindingContext(), constructor)
|
||||
as ClassConstructorDescriptor
|
||||
val classDescriptor = constructorDescriptor.containingDeclaration
|
||||
|
||||
val constructorScope = classContext.getScopeForDescriptor(constructorDescriptor)
|
||||
@@ -201,7 +202,7 @@ class ClassTranslator private constructor(
|
||||
|
||||
// Generate super/this call to insert to beginning of the function
|
||||
val resolvedCall = BindingContextUtils.getDelegationConstructorCall(context.bindingContext(), constructorDescriptor)
|
||||
val delegationClassDescriptor = resolvedCall?.resultingDescriptor?.containingDeclaration
|
||||
val delegationClassDescriptor = (resolvedCall?.resultingDescriptor as? ClassConstructorDescriptor)?.constructedClass
|
||||
|
||||
if (resolvedCall != null && !KotlinBuiltIns.isAny(delegationClassDescriptor!!)) {
|
||||
superCallGenerators += {
|
||||
|
||||
+1
-1
@@ -92,7 +92,7 @@ class JsDataClassGenerator extends DataClassMethodGenerator {
|
||||
}
|
||||
|
||||
ClassDescriptor classDescriptor = (ClassDescriptor) function.getContainingDeclaration();
|
||||
ConstructorDescriptor constructor = classDescriptor.getConstructors().iterator().next();
|
||||
ClassConstructorDescriptor constructor = classDescriptor.getConstructors().iterator().next();
|
||||
|
||||
JsExpression constructorRef = context.getQualifiedReference(constructor);
|
||||
|
||||
|
||||
@@ -25,7 +25,7 @@ import org.jetbrains.annotations.NotNull;
|
||||
import org.jetbrains.kotlin.backend.common.CodegenUtil;
|
||||
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.incremental.components.NoLookupLocation;
|
||||
import org.jetbrains.kotlin.js.descriptorUtils.DescriptorUtilsKt;
|
||||
import org.jetbrains.kotlin.name.FqNameUnsafe;
|
||||
@@ -57,7 +57,7 @@ public class ManglingUtils {
|
||||
suggestedName = getMangledName((CallableMemberDescriptor) descriptor);
|
||||
}
|
||||
|
||||
ClassDescriptor localClass = null;
|
||||
ClassifierDescriptorWithTypeParameters localClass = null;
|
||||
if (descriptor instanceof ConstructorDescriptor) {
|
||||
ConstructorDescriptor constructor = (ConstructorDescriptor) descriptor;
|
||||
localClass = constructor.getContainingDeclaration();
|
||||
@@ -210,11 +210,12 @@ public class ManglingUtils {
|
||||
public Iterable<? extends CallableDescriptor> invoke(DeclarationDescriptor declarationDescriptor) {
|
||||
if (declarationDescriptor instanceof ClassDescriptor && finalNameToCompare.equals(declarationDescriptor.getName().asString())) {
|
||||
ClassDescriptor classDescriptor = (ClassDescriptor) declarationDescriptor;
|
||||
Collection<ConstructorDescriptor> constructors = classDescriptor.getConstructors();
|
||||
Collection<ClassConstructorDescriptor> constructors = classDescriptor.getConstructors();
|
||||
|
||||
if (!DescriptorUtilsKt.hasPrimaryConstructor(classDescriptor)) {
|
||||
ConstructorDescriptorImpl fakePrimaryConstructor =
|
||||
ConstructorDescriptorImpl.create(classDescriptor, Annotations.Companion.getEMPTY(), true, SourceElement.NO_SOURCE);
|
||||
ClassConstructorDescriptorImpl fakePrimaryConstructor =
|
||||
ClassConstructorDescriptorImpl
|
||||
.create(classDescriptor, Annotations.Companion.getEMPTY(), true, SourceElement.NO_SOURCE);
|
||||
return CollectionsKt.plus(constructors, fakePrimaryConstructor);
|
||||
}
|
||||
|
||||
|
||||
@@ -16,6 +16,7 @@
|
||||
|
||||
package org.jetbrains.kotlin.uast
|
||||
|
||||
import org.jetbrains.kotlin.descriptors.ClassConstructorDescriptor
|
||||
import org.jetbrains.kotlin.descriptors.ClassDescriptor
|
||||
import org.jetbrains.kotlin.descriptors.ConstructorDescriptor
|
||||
import org.jetbrains.kotlin.idea.caches.resolve.analyze
|
||||
@@ -49,7 +50,7 @@ class KotlinUAnnotation(
|
||||
private fun resolveToDescriptor(): ClassDescriptor? {
|
||||
val bindingContext = psi.analyze(BodyResolveMode.PARTIAL)
|
||||
val resolvedCall = psi.calleeExpression?.getResolvedCall(bindingContext) ?: return null
|
||||
return (resolvedCall.resultingDescriptor as? ConstructorDescriptor)?.containingDeclaration
|
||||
return (resolvedCall.resultingDescriptor as? ClassConstructorDescriptor)?.containingDeclaration
|
||||
}
|
||||
|
||||
override fun resolve(context: UastContext): UClass? {
|
||||
|
||||
Reference in New Issue
Block a user