[UAST] Fix mapping types containing type aliases
#KT-27935 Fixed
This commit is contained in:
@@ -19,7 +19,8 @@ class TypeMappingMode private constructor(
|
||||
private val genericArgumentMode: TypeMappingMode? = null,
|
||||
val kotlinCollectionsToJavaCollections: Boolean = true,
|
||||
private val genericContravariantArgumentMode: TypeMappingMode? = genericArgumentMode,
|
||||
private val genericInvariantArgumentMode: TypeMappingMode? = genericArgumentMode
|
||||
private val genericInvariantArgumentMode: TypeMappingMode? = genericArgumentMode,
|
||||
val mapTypeAliases: Boolean = false
|
||||
) {
|
||||
companion object {
|
||||
/**
|
||||
@@ -28,6 +29,13 @@ class TypeMappingMode private constructor(
|
||||
@JvmField
|
||||
val GENERIC_ARGUMENT = TypeMappingMode()
|
||||
|
||||
/**
|
||||
* kotlin.Int is mapped to Ljava/lang/Integer;
|
||||
* Type aliases are mapped to their expanded form
|
||||
*/
|
||||
@JvmField
|
||||
val GENERIC_ARGUMENT_UAST = TypeMappingMode(mapTypeAliases = true)
|
||||
|
||||
/**
|
||||
* see KotlinTypeMapper.forceBoxedReturnType()
|
||||
* This configuration should be called only for method return type
|
||||
@@ -41,6 +49,18 @@ class TypeMappingMode private constructor(
|
||||
@JvmField
|
||||
val DEFAULT = TypeMappingMode(genericArgumentMode = GENERIC_ARGUMENT, needPrimitiveBoxing = false, needInlineClassWrapping = false)
|
||||
|
||||
/**
|
||||
* kotlin.Int is mapped to I
|
||||
* Type aliases are mapped to their expanded form
|
||||
*/
|
||||
@JvmField
|
||||
val DEFAULT_UAST = TypeMappingMode(
|
||||
genericArgumentMode = GENERIC_ARGUMENT_UAST,
|
||||
needPrimitiveBoxing = false,
|
||||
needInlineClassWrapping = false,
|
||||
mapTypeAliases = true
|
||||
)
|
||||
|
||||
/**
|
||||
* kotlin.Int is mapped to I
|
||||
* inline class Foo(val x: Int) is mapped to LFoo;
|
||||
@@ -133,12 +153,14 @@ class TypeMappingMode private constructor(
|
||||
skipDeclarationSiteWildcards: Boolean,
|
||||
isForAnnotationParameter: Boolean,
|
||||
needInlineClassWrapping: Boolean,
|
||||
mapTypeAliases: Boolean,
|
||||
fallbackMode: TypeMappingMode? = null
|
||||
) = TypeMappingMode(
|
||||
isForAnnotationParameter = isForAnnotationParameter,
|
||||
skipDeclarationSiteWildcards = skipDeclarationSiteWildcards,
|
||||
genericArgumentMode = fallbackMode,
|
||||
needInlineClassWrapping = needInlineClassWrapping
|
||||
needInlineClassWrapping = needInlineClassWrapping,
|
||||
mapTypeAliases = mapTypeAliases
|
||||
)
|
||||
}
|
||||
|
||||
|
||||
@@ -173,6 +173,10 @@ fun <T : Any> mapType(
|
||||
return type
|
||||
}
|
||||
|
||||
descriptor is TypeAliasDescriptor && mode.mapTypeAliases -> {
|
||||
return mapType(descriptor.expandedType, factory, mode, typeMappingConfiguration, descriptorTypeWriter, writeGenericType)
|
||||
}
|
||||
|
||||
else -> throw UnsupportedOperationException("Unknown type $kotlinType")
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user