Add correct type parameter information to synthetic declarations

Needed by kapt due to https://github.com/Kotlin/kotlinx.serialization/issues/76
This commit is contained in:
Leonid Startsev
2018-04-18 18:21:15 +03:00
committed by Leonid Startsev
parent adc3e61742
commit 666553e413
@@ -50,13 +50,15 @@ class SyntheticClassOrObjectDescriptor(
val syntheticDeclaration: KtPureClassOrObject = SyntheticDeclaration(parentClassOrObject, name.asString())
private val thisDescriptor: SyntheticClassOrObjectDescriptor get() = this // code readability
var typeParameters: List<TypeParameterDescriptor> = emptyList()
private val typeConstructor = SyntheticTypeConstructor(c.storageManager)
private val resolutionScopesSupport = ClassResolutionScopesSupport(thisDescriptor, c.storageManager, c.languageVersionSettings, { outerScope })
private val syntheticSupertypes =
mutableListOf<KotlinType>().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<TypeParameterDescriptor>()
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<ClassDescriptor>()
@@ -110,7 +112,7 @@ class SyntheticClassOrObjectDescriptor(
}
private inner class SyntheticTypeConstructor(storageManager: StorageManager) : AbstractClassTypeConstructor(storageManager) {
override fun getParameters(): List<TypeParameterDescriptor> = emptyList()
override fun getParameters(): List<TypeParameterDescriptor> = typeParameters
override fun isDenotable(): Boolean = true
override fun getDeclarationDescriptor(): ClassDescriptor = thisDescriptor
override fun computeSupertypes(): Collection<KotlinType> = syntheticSupertypes