We often have a sealed class with subclasses which are either data class or object:
sealed class AuthResponse {
object Success : AuthResponse()
object WrongUsernameOrPassword : AuthResponse()
data class VerificationCodeRequired(
val options: VerificationCodeOption
) : AuthResponse()
}
And while data classes have a nice auto-generated toString
method, for objects there isn’t anything like this and toString
will return ridiculous result such as:
com.google.firebase.oauth.AuthResponse$Success@7e94e331
Which is very inconvenient. Could we generate a toString
for objects which only prints the simple name? Perhaps this can be done only if they are inside a sealed class.