ClassDescriptor is now a super-interface for ClassConstructorDescriptor and TypeAliasConstructorDescriptor.
This commit is contained in:
committed by
Dmitry Petrov
parent
7d214c6e58
commit
796d11c860
+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);
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user