Skip to content

Commit 131632e

Browse files
committed
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.
1 parent b0ae128 commit 131632e

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)