Use underlying type when computing type mapping mode for inline classes
This commit is contained in:
@@ -103,6 +103,13 @@ class TypeMappingMode private constructor(
|
||||
): TypeMappingMode {
|
||||
if (type.arguments.isEmpty()) return DEFAULT
|
||||
|
||||
if (type.isInlineClassType() && shouldUseUnderlyingType(type)) {
|
||||
val underlyingType = computeUnderlyingType(type)
|
||||
if (underlyingType != null) {
|
||||
return getOptimalModeForSignaturePart(underlyingType, isForAnnotationParameter, canBeUsedInSupertypePosition)
|
||||
}
|
||||
}
|
||||
|
||||
val contravariantArgumentMode =
|
||||
if (!canBeUsedInSupertypePosition)
|
||||
TypeMappingMode(
|
||||
|
||||
@@ -240,7 +240,7 @@ private fun <T : Any> mapBuiltInType(
|
||||
return null
|
||||
}
|
||||
|
||||
private fun computeUnderlyingType(inlineClassType: KotlinType): KotlinType? {
|
||||
internal fun computeUnderlyingType(inlineClassType: KotlinType): KotlinType? {
|
||||
if (!shouldUseUnderlyingType(inlineClassType)) return null
|
||||
|
||||
val descriptor = inlineClassType.unsubstitutedUnderlyingType()?.constructor?.declarationDescriptor ?: return null
|
||||
@@ -250,7 +250,7 @@ private fun computeUnderlyingType(inlineClassType: KotlinType): KotlinType? {
|
||||
inlineClassType.substitutedUnderlyingType()
|
||||
}
|
||||
|
||||
private fun shouldUseUnderlyingType(inlineClassType: KotlinType): Boolean {
|
||||
internal fun shouldUseUnderlyingType(inlineClassType: KotlinType): Boolean {
|
||||
val underlyingType = inlineClassType.unsubstitutedUnderlyingType() ?: return false
|
||||
|
||||
return !inlineClassType.isMarkedNullable ||
|
||||
|
||||
Reference in New Issue
Block a user