If you select Any or AnyVal , then any primitive that you pass will be boxed to probably exit.
AnyRef really good choice.
If there is no parameterization of parameters, then "primitives" are also good options - Boolean or Int , for example.
And there is also Null , which is a very interesting choice, because it does not highlight anything at all, and it is literal, so it should be fast. Not knowing what exactly you are doing with this, I can’t say whether this choice really is.
Another interesting option is java.lang.Integer (using the static valueOf method), since it guarantees reference equality for small values (you will need to check the documents to find out what the exact range is), which means no allocation.
Daniel C. Sobral
source share