[StubIR][Metadata] Fix type aliases with arguments

This commit is contained in:
Sergey Bogolepov
2020-02-14 10:54:09 +07:00
committed by Sergey Bogolepov
parent 04b8bc9539
commit bf1eabca33
@@ -445,19 +445,21 @@ private class MappingExtensions(
fun StubType.map(shouldExpandTypeAliases: Boolean = true): KmType = when (this) { fun StubType.map(shouldExpandTypeAliases: Boolean = true): KmType = when (this) {
is AbbreviatedType -> { is AbbreviatedType -> {
val typeAliasClassifier = KmClassifier.TypeAlias(abbreviatedClassifier.fqNameSerialized) val typeAliasClassifier = KmClassifier.TypeAlias(abbreviatedClassifier.fqNameSerialized)
val typeArguments = typeArguments.map { it.map(shouldExpandTypeAliases) }
val abbreviatedType = KmType(flags).also { km ->
km.classifier = typeAliasClassifier
km.arguments += typeArguments
}
if (shouldExpandTypeAliases) { if (shouldExpandTypeAliases) {
// Abbreviated and expanded types have the same nullability. // Abbreviated and expanded types have the same nullability.
KmType(flags).also { km -> KmType(flags).also { km ->
km.abbreviatedType = KmType(flags).also { abbreviatedType -> km.abbreviatedType = abbreviatedType
abbreviatedType.classifier = typeAliasClassifier
typeArguments.mapTo(abbreviatedType.arguments) { it.map(shouldExpandTypeAliases) }
}
val kmUnderlyingType = underlyingType.map(true) val kmUnderlyingType = underlyingType.map(true)
km.arguments += kmUnderlyingType.arguments km.arguments += kmUnderlyingType.arguments
km.classifier = kmUnderlyingType.classifier km.classifier = kmUnderlyingType.classifier
} }
} else { } else {
KmType(flags).also { km -> km.classifier = typeAliasClassifier } abbreviatedType
} }
} }
is ClassifierStubType -> KmType(flags).also { km -> is ClassifierStubType -> KmType(flags).also { km ->