Kotlin: Remove a cast from substituteTypeAndArguments

It looks like it was safe, but it was hard to see why, and may
become unsafe following future kotlinc changes.
This commit is contained in:
Ian Lynagh
2022-08-26 13:06:05 +01:00
parent b0ae12850d
commit 131632e7c1

View File

@@ -123,14 +123,17 @@ private fun IrTypeArgument.lowerBound(context: IrPluginContext) =
fun IrType.substituteTypeAndArguments(substitutionMap: Map<IrTypeParameterSymbol, IrTypeArgument>?, useContext: KotlinUsesExtractor.TypeContext, pluginContext: IrPluginContext): IrType =
substitutionMap?.let { substMap ->
this.classifierOrNull?.let { typeClassifier ->
if (this is IrSimpleType) {
val typeClassifier = this.classifier
substMap[typeClassifier]?.let {
when(useContext) {
KotlinUsesExtractor.TypeContext.RETURN -> it.upperBound(pluginContext)
else -> it.lowerBound(pluginContext)
}
} ?: (this as IrSimpleType).substituteTypeArguments(substMap)
} ?: this
} ?: this.substituteTypeArguments(substMap)
} else {
this
}
} ?: this
object RawTypeAnnotation {