Use TypeSubstitutor to get the substituted underlying type for inline

classes, instead of MemberScope.

The primary motivation was to fix issues around type-mapping for inline
classes in FIR, which uses wrapped descriptors that have empty
MemberScopes.
This commit is contained in:
Mark Punzalan
2020-05-29 16:02:58 -07:00
committed by Mikhail Glukhikh
parent 88b130308d
commit 802beb49a6
27 changed files with 3 additions and 27 deletions
@@ -8,7 +8,9 @@ package org.jetbrains.kotlin.resolve
import org.jetbrains.kotlin.descriptors.*
import org.jetbrains.kotlin.incremental.components.NoLookupLocation
import org.jetbrains.kotlin.types.KotlinType
import org.jetbrains.kotlin.types.TypeSubstitutor
import org.jetbrains.kotlin.types.TypeUtils
import org.jetbrains.kotlin.types.Variance
import org.jetbrains.kotlin.utils.addToStdlib.safeAs
fun ClassDescriptor.underlyingRepresentation(): ValueParameterDescriptor? {
@@ -28,7 +30,7 @@ fun KotlinType.isInlineClassType(): Boolean = constructor.declarationDescriptor?
fun KotlinType.substitutedUnderlyingType(): KotlinType? {
val parameter = unsubstitutedUnderlyingParameter() ?: return null
return memberScope.getContributedVariables(parameter.name, NoLookupLocation.FOR_ALREADY_TRACKED).singleOrNull()?.type
return TypeSubstitutor.create(this).substitute(parameter.type, Variance.INVARIANT)
}
fun KotlinType.isRecursiveInlineClassType() =