Tóth István Zoltán
01/21/2025, 6:56 AMIrVarargElement
into IrExpression
? The IDE shows an error if I try to use a non-expression as vararg argument, but the type structure allows IrVarargElement
to be anything basically.Pavel Kunyavskiy [JB]
01/22/2025, 8:37 AMIrVarargElement
. It's either any IrExpression
or IrSpreadElement
.
The later corresponds to
val a = intArrayOf(1, 2, 3) // IrVararg(IrExp(1), IrExp(2), IrExp(3)
val b = intArrayOf(4, 5, 6) // IrVararg(IrExp(4), IrExp(5), IrExp(6)
listOf(*a, *b) // IrVararg(IrSpread(IrGet(a)), IrSpread(IrGet(b)))
IrSpreadElement is not an expression, so it's not safe to cast in general case, unless you know something about the code you are processing.
In the current language, there is nothing else can be in IR here. Technically, some compiler plugin can insert it's own implementor of interface, but it probably wouldn't work anyway, so I doubt someone really do this.Tóth István Zoltán
01/22/2025, 8:50 AMIrSpreadElement
as well.