Skip to content

Commit a5893f3

Browse files
authored
Merge pull request #10189 from igfoo/igfoo/substituteTypeAndArguments
Kotlin: Remove a cast from substituteTypeAndArguments
2 parents d6bdc8c + 131632e commit a5893f3

File tree

1 file changed

+6
-3
lines changed

1 file changed

+6
-3
lines changed

java/kotlin-extractor/src/main/kotlin/utils/TypeSubstitution.kt

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -123,14 +123,17 @@ private fun IrTypeArgument.lowerBound(context: IrPluginContext) =
123123

124124
fun IrType.substituteTypeAndArguments(substitutionMap: Map<IrTypeParameterSymbol, IrTypeArgument>?, useContext: KotlinUsesExtractor.TypeContext, pluginContext: IrPluginContext): IrType =
125125
substitutionMap?.let { substMap ->
126-
this.classifierOrNull?.let { typeClassifier ->
126+
if (this is IrSimpleType) {
127+
val typeClassifier = this.classifier
127128
substMap[typeClassifier]?.let {
128129
when(useContext) {
129130
KotlinUsesExtractor.TypeContext.RETURN -> it.upperBound(pluginContext)
130131
else -> it.lowerBound(pluginContext)
131132
}
132-
} ?: (this as IrSimpleType).substituteTypeArguments(substMap)
133-
} ?: this
133+
} ?: this.substituteTypeArguments(substMap)
134+
} else {
135+
this
136+
}
134137
} ?: this
135138

136139
object RawTypeAnnotation {

0 commit comments

Comments
 (0)