If you used overloaded functions, the type system would alert you to the fact that you are calling a non-existing function if you passed it an argument for which it wasn't defined, you don't need unions for that. Unions are really only useful when you want to return different types of values. In the when statement, you always have to have an "else" branch which would catch your case, so you also wouldn't find out at run-time, barring the situation where you intended to implement custom logic for a specific type but just forgot to do it. In certain situations you could possibly use a when statement and sealed classes (
https://kotlinlang.org/docs/reference/sealed-classes.html). Or create a "Logable" interface with a custom log function and have all the classes you need implement it. There really are a lot of options and without more info about your use case, I can't give you a better recommendation.