Closed
Description
I've been using a lot of inline lately and I'm seeing the following bytecode in a lot of places:
N: getstatic #54 // Field scala/runtime/BoxedUnit.UNIT:Lscala/runtime/BoxedUnit;
N+1: pop
This stems from doing Tuple-pair-wise-peel-off(tm), basically:
inline def doNextThing[Elems](idx: Int, p: Product): Unit =
inline erasedValue match {
case _: (a *: b) => doThing[a](p.productElement(idx).asInstanceOf)
case _: Unit => () // Base case
}
I had thought the empty ()
would get removed from the AST/generated code, but it seems to show up in bytecode. Additionally, when doing nested Product types with the same technique, I see BoxedUnit accessed and discarded at every nested-product boundary.