diff --git a/compiler/frontend/src/org/jetbrains/kotlin/psi/synthetics/SyntheticClassOrObjectDescriptor.kt b/compiler/frontend/src/org/jetbrains/kotlin/psi/synthetics/SyntheticClassOrObjectDescriptor.kt index 092d7b02ce5..0e4e807d3f8 100644 --- a/compiler/frontend/src/org/jetbrains/kotlin/psi/synthetics/SyntheticClassOrObjectDescriptor.kt +++ b/compiler/frontend/src/org/jetbrains/kotlin/psi/synthetics/SyntheticClassOrObjectDescriptor.kt @@ -50,15 +50,21 @@ class SyntheticClassOrObjectDescriptor( val syntheticDeclaration: KtPureClassOrObject = SyntheticDeclaration(parentClassOrObject, name.asString()) private val thisDescriptor: SyntheticClassOrObjectDescriptor get() = this // code readability - var typeParameters: List = emptyList() + private lateinit var typeParameters: List private val typeConstructor = SyntheticTypeConstructor(c.storageManager) private val resolutionScopesSupport = ClassResolutionScopesSupport(thisDescriptor, c.storageManager, c.languageVersionSettings, { outerScope }) private val syntheticSupertypes = mutableListOf().apply { c.syntheticResolveExtension.addSyntheticSupertypes(thisDescriptor, this) } private val unsubstitutedMemberScope = LazyClassMemberScope(c, SyntheticClassMemberDeclarationProvider(syntheticDeclaration), this, c.trace) - private val _unsubstitutedPrimaryConstructor by lazy { createUnsubstitutedPrimaryConstructor(constructorVisibility) } + private val _unsubstitutedPrimaryConstructor = + c.storageManager.createLazyValue { createUnsubstitutedPrimaryConstructor(constructorVisibility) } + + @JvmOverloads + fun initialize(typeParameters: List = emptyList()) { + this.typeParameters = typeParameters + } override val annotations: Annotations get() = Annotations.EMPTY @@ -74,8 +80,8 @@ class SyntheticClassOrObjectDescriptor( override fun getCompanionObjectDescriptor(): ClassDescriptorWithResolutionScopes? = null override fun getTypeConstructor(): TypeConstructor = typeConstructor - override fun getUnsubstitutedPrimaryConstructor() = _unsubstitutedPrimaryConstructor - override fun getConstructors() = listOf(_unsubstitutedPrimaryConstructor) + override fun getUnsubstitutedPrimaryConstructor() = _unsubstitutedPrimaryConstructor() + override fun getConstructors() = listOf(_unsubstitutedPrimaryConstructor()) override fun getDeclaredTypeParameters() = typeParameters override fun getStaticScope() = MemberScope.Empty override fun getUnsubstitutedMemberScope() = unsubstitutedMemberScope diff --git a/compiler/frontend/src/org/jetbrains/kotlin/resolve/lazy/descriptors/LazyClassDescriptor.java b/compiler/frontend/src/org/jetbrains/kotlin/resolve/lazy/descriptors/LazyClassDescriptor.java index 64e8b235d9d..f5fec1c87b2 100644 --- a/compiler/frontend/src/org/jetbrains/kotlin/resolve/lazy/descriptors/LazyClassDescriptor.java +++ b/compiler/frontend/src/org/jetbrains/kotlin/resolve/lazy/descriptors/LazyClassDescriptor.java @@ -435,11 +435,13 @@ public class LazyClassDescriptor extends ClassDescriptorBase implements ClassDes Name syntheticCompanionName = c.getSyntheticResolveExtension().getSyntheticCompanionObjectNameIfNeeded(this); if (syntheticCompanionName == null) return null; - return new SyntheticClassOrObjectDescriptor(c, + SyntheticClassOrObjectDescriptor companionDescriptor = new SyntheticClassOrObjectDescriptor(c, /* parentClassOrObject= */ classOrObject, this, syntheticCompanionName, getSource(), /* outerScope= */ getOuterScope(), Modality.FINAL, PUBLIC, PRIVATE, ClassKind.OBJECT, true); + companionDescriptor.initialize(); + return companionDescriptor; } @Nullable