[Commonizer] Don't serialize kotlin/Any? as the single type parameter upper bound

This commit is contained in:
Dmitriy Dolovov
2021-01-30 13:10:26 +03:00
parent 1c8cd242bf
commit dfd1a53624
@@ -14,15 +14,21 @@ import org.jetbrains.kotlin.descriptors.commonizer.utils.compactMap
import org.jetbrains.kotlin.descriptors.commonizer.utils.intern
import org.jetbrains.kotlin.name.Name
import org.jetbrains.kotlin.types.Variance
import org.jetbrains.kotlin.types.typeUtil.isNullableAny
object CirTypeParameterFactory {
fun create(source: TypeParameterDescriptor): CirTypeParameter = create(
annotations = source.annotations.compactMap(CirAnnotationFactory::create),
name = source.name.intern(),
isReified = source.isReified,
variance = source.variance,
upperBounds = source.upperBounds.compactMap(CirTypeFactory::create)
)
fun create(source: TypeParameterDescriptor): CirTypeParameter {
val upperBounds = source.upperBounds
val filteredUpperBounds = if (upperBounds.singleOrNull()?.isNullableAny() == true) emptyList() else upperBounds
return create(
annotations = source.annotations.compactMap(CirAnnotationFactory::create),
name = source.name.intern(),
isReified = source.isReified,
variance = source.variance,
upperBounds = filteredUpperBounds.compactMap(CirTypeFactory::create)
)
}
@Suppress("NOTHING_TO_INLINE")
inline fun create(