If I understood the Scala documentation correctly “Value classes” can extend universal traits but extending traits requires to allocate memory (Universal traits allow basic inheritance of methods for value classes, but they incur the overhead of allocation).
What is not clear in the documentation is the circumstances where the memory allocation is required (systematically or when a method of the trait is called). So I think the documentation could be more detailed on this specific point.
Now my question: I was wondering if the boxing/instantiation of value class could be avoided when the universal trait is sealed.
It would allow to have multiple value classes extending a fixed set of methods. The methods of the “sealed universal trait” could eventually inlined in the singleton generated by the compiler.