Skip to content

Commit

Permalink
[Commonizer] Substitute type arguments when argument type is ClassOrT…
Browse files Browse the repository at this point in the history
…ypeAlias type

^KT-51686 Verification Pending

(cherry picked from commit a08fdcf)
  • Loading branch information
sellmair committed Mar 25, 2022
1 parent 53676cb commit 2397635
Showing 1 changed file with 12 additions and 6 deletions.
18 changes: 12 additions & 6 deletions native/commonizer/src/org/jetbrains/kotlin/commonizer/cir/utils.kt
Original file line number Diff line number Diff line change
Expand Up @@ -91,15 +91,21 @@ internal fun CirClassOrTypeAliasType.withParentArguments(

val newArguments = arguments.map { oldArgument ->
if (oldArgument !is CirRegularTypeProjection) return@map oldArgument
if (oldArgument.type !is CirTypeParameterType) return@map oldArgument
parentArguments[oldArgument.type.index]

when (val type = oldArgument.type) {
is CirTypeParameterType -> parentArguments[type.index]
is CirClassOrTypeAliasType -> CirRegularTypeProjection(
oldArgument.projectionKind, type.withParentArguments(parentArguments, parentIsMarkedNullable)
)
else -> oldArgument
}
}

return when (val newUnderlyingType = makeNullableIfNecessary(newIsMarkedNullable).withArguments(newArguments)) {
return when (val newType = makeNullableIfNecessary(newIsMarkedNullable).withArguments(newArguments)) {
this -> this
is CirClassType -> newUnderlyingType
is CirTypeAliasType -> newUnderlyingType.withUnderlyingType(
newUnderlyingType.underlyingType.withParentArguments(parentArguments, newIsMarkedNullable)
is CirClassType -> newType
is CirTypeAliasType -> newType.withUnderlyingType(
newType.underlyingType.withParentArguments(parentArguments, newIsMarkedNullable)
)
}
}
Expand Down

0 comments on commit 2397635

Please sign in to comment.