From 666553e413eaf3663feed6383c62835ed242815c Mon Sep 17 00:00:00 2001 From: Leonid Startsev Date: Wed, 18 Apr 2018 18:21:15 +0300 Subject: [PATCH] Add correct type parameter information to synthetic declarations Needed by kapt due to https://github.com/Kotlin/kotlinx.serialization/issues/76 --- .../synthetics/SyntheticClassOrObjectDescriptor.kt | 14 ++++++++------ 1 file changed, 8 insertions(+), 6 deletions(-) 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 00339d43728..092d7b02ce5 100644 --- a/compiler/frontend/src/org/jetbrains/kotlin/psi/synthetics/SyntheticClassOrObjectDescriptor.kt +++ b/compiler/frontend/src/org/jetbrains/kotlin/psi/synthetics/SyntheticClassOrObjectDescriptor.kt @@ -50,13 +50,15 @@ class SyntheticClassOrObjectDescriptor( val syntheticDeclaration: KtPureClassOrObject = SyntheticDeclaration(parentClassOrObject, name.asString()) private val thisDescriptor: SyntheticClassOrObjectDescriptor get() = this // code readability + var typeParameters: List = emptyList() + 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 = createUnsubstitutedPrimaryConstructor(constructorVisibility) + private val _unsubstitutedPrimaryConstructor by lazy { createUnsubstitutedPrimaryConstructor(constructorVisibility) } override val annotations: Annotations get() = Annotations.EMPTY @@ -70,11 +72,11 @@ class SyntheticClassOrObjectDescriptor( override fun isExpect() = false override fun isActual() = false - override fun getCompanionObjectDescriptor() = null + override fun getCompanionObjectDescriptor(): ClassDescriptorWithResolutionScopes? = null override fun getTypeConstructor(): TypeConstructor = typeConstructor - override fun getUnsubstitutedPrimaryConstructor() = unsubstitutedPrimaryConstructor - override fun getConstructors() = listOf(unsubstitutedPrimaryConstructor) - override fun getDeclaredTypeParameters() = emptyList() + override fun getUnsubstitutedPrimaryConstructor() = _unsubstitutedPrimaryConstructor + override fun getConstructors() = listOf(_unsubstitutedPrimaryConstructor) + override fun getDeclaredTypeParameters() = typeParameters override fun getStaticScope() = MemberScope.Empty override fun getUnsubstitutedMemberScope() = unsubstitutedMemberScope override fun getSealedSubclasses() = emptyList() @@ -110,7 +112,7 @@ class SyntheticClassOrObjectDescriptor( } private inner class SyntheticTypeConstructor(storageManager: StorageManager) : AbstractClassTypeConstructor(storageManager) { - override fun getParameters(): List = emptyList() + override fun getParameters(): List = typeParameters override fun isDenotable(): Boolean = true override fun getDeclarationDescriptor(): ClassDescriptor = thisDescriptor override fun computeSupertypes(): Collection = syntheticSupertypes