mirror of
https://github.com/github/codeql.git
synced 2025-12-22 19:56:32 +01:00
Kotlin: Refactor useSimpleType to avoid some casts
This commit is contained in:
@@ -667,11 +667,15 @@ open class KotlinUsesExtractor(
|
|||||||
dimensions++
|
dimensions++
|
||||||
if (elementType.isPrimitiveArray())
|
if (elementType.isPrimitiveArray())
|
||||||
isPrimitiveArray = true
|
isPrimitiveArray = true
|
||||||
if (((elementType as IrSimpleType).arguments.singleOrNull() as? IrTypeProjection)?.variance == Variance.IN_VARIANCE) {
|
if (elementType is IrSimpleType) {
|
||||||
// Because Java's arrays are covariant, Kotlin will render Array<in X> as Object[], Array<Array<in X>> as Object[][] etc.
|
if ((elementType.arguments.singleOrNull() as? IrTypeProjection)?.variance == Variance.IN_VARIANCE) {
|
||||||
componentType = replaceComponentTypeWithAny(s, dimensions - 1)
|
// Because Java's arrays are covariant, Kotlin will render Array<in X> as Object[], Array<Array<in X>> as Object[][] etc.
|
||||||
elementType = pluginContext.irBuiltIns.anyType as IrSimpleType
|
componentType = replaceComponentTypeWithAny(s, dimensions - 1)
|
||||||
break
|
elementType = pluginContext.irBuiltIns.anyType
|
||||||
|
break
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
logger.warn("Unexpected element type representation ${elementType.javaClass} for ${s.render()}")
|
||||||
}
|
}
|
||||||
elementType = elementType.getArrayElementType(pluginContext.irBuiltIns)
|
elementType = elementType.getArrayElementType(pluginContext.irBuiltIns)
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user