Opaque Types vs AnyVal Wrappers for a Cross-Built Scala Library
A library that cross-builds for Scala 2.13 and Scala 3 needs a zero-cost wrapper for identifiers in a hot path, while keeping the public API distinct from the underlying type. Two documented options are Scala 3 opaque type aliases and value classes that extend AnyVal . Opaque types hide their representation outside the defining scope and are erased to the un