Support mapping for inline classes based on type variables
This commit is contained in:
@@ -8,6 +8,7 @@ package org.jetbrains.kotlin.resolve
|
||||
import org.jetbrains.kotlin.descriptors.ClassDescriptor
|
||||
import org.jetbrains.kotlin.descriptors.DeclarationDescriptor
|
||||
import org.jetbrains.kotlin.descriptors.ValueParameterDescriptor
|
||||
import org.jetbrains.kotlin.incremental.components.NoLookupLocation
|
||||
import org.jetbrains.kotlin.types.KotlinType
|
||||
import org.jetbrains.kotlin.utils.addToStdlib.safeAs
|
||||
|
||||
@@ -18,8 +19,15 @@ fun ClassDescriptor.underlyingRepresentation(): ValueParameterDescriptor? {
|
||||
|
||||
fun DeclarationDescriptor.isInlineClass() = this is ClassDescriptor && this.isInline
|
||||
|
||||
fun KotlinType.underlyingTypeOfInlineClassType(): KotlinType? {
|
||||
return constructor.declarationDescriptor.safeAs<ClassDescriptor>()?.underlyingRepresentation()?.type
|
||||
fun KotlinType.unsubstitutedUnderlyingParameter(): ValueParameterDescriptor? {
|
||||
return constructor.declarationDescriptor.safeAs<ClassDescriptor>()?.underlyingRepresentation()
|
||||
}
|
||||
|
||||
fun KotlinType.isInlineClassType(): Boolean = constructor.declarationDescriptor?.isInlineClass() ?: false
|
||||
fun KotlinType.unsubstitutedUnderlyingType(): KotlinType? = unsubstitutedUnderlyingParameter()?.type
|
||||
|
||||
fun KotlinType.isInlineClassType(): Boolean = constructor.declarationDescriptor?.isInlineClass() ?: false
|
||||
|
||||
fun KotlinType.substitutedUnderlyingType(): KotlinType? {
|
||||
val parameter = unsubstitutedUnderlyingParameter() ?: return null
|
||||
return memberScope.getContributedVariables(parameter.name, NoLookupLocation.FOR_ALREADY_TRACKED).singleOrNull()?.type
|
||||
}
|
||||
Reference in New Issue
Block a user