Skip to content

Commit a07be19

Browse files
committed
Kotlin: Refactor useSimpleType to avoid some casts
1 parent f5d43b8 commit a07be19

File tree

1 file changed

+9
-5
lines changed

1 file changed

+9
-5
lines changed

java/kotlin-extractor/src/main/kotlin/KotlinUsesExtractor.kt

Lines changed: 9 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -667,11 +667,15 @@ open class KotlinUsesExtractor(
667667
dimensions++
668668
if (elementType.isPrimitiveArray())
669669
isPrimitiveArray = true
670-
if (((elementType as IrSimpleType).arguments.singleOrNull() as? IrTypeProjection)?.variance == Variance.IN_VARIANCE) {
671-
// Because Java's arrays are covariant, Kotlin will render Array<in X> as Object[], Array<Array<in X>> as Object[][] etc.
672-
componentType = replaceComponentTypeWithAny(s, dimensions - 1)
673-
elementType = pluginContext.irBuiltIns.anyType as IrSimpleType
674-
break
670+
if (elementType is IrSimpleType) {
671+
if ((elementType.arguments.singleOrNull() as? IrTypeProjection)?.variance == Variance.IN_VARIANCE) {
672+
// Because Java's arrays are covariant, Kotlin will render Array<in X> as Object[], Array<Array<in X>> as Object[][] etc.
673+
componentType = replaceComponentTypeWithAny(s, dimensions - 1)
674+
elementType = pluginContext.irBuiltIns.anyType
675+
break
676+
}
677+
} else {
678+
logger.warn("Unexpected element type representation ${elementType.javaClass} for ${s.render()}")
675679
}
676680
elementType = elementType.getArrayElementType(pluginContext.irBuiltIns)
677681
}

0 commit comments

Comments
 (0)