Ensure enum classes toString() returns kotlin.String (#16247)

When creating an enum where a valid value is `String`, the override of toString() will be the wrong type.

Simply using `*kotlin*.String` will allow using `String` as a value in an enum.
This commit is contained in:
André Roaldseth 2023-08-09 09:09:21 +02:00 committed by GitHub
parent 6a8039c672
commit 75b04bb965
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 2 additions and 2 deletions

View File

@ -74,7 +74,7 @@ import kotlinx.serialization.*
* This solves a problem when the variable name and its value are different, and ensures that
* the client sends the correct enum values to the server always.
*/
override fun toString(): String = value{{^isString}}.toString(){{/isString}}
override fun toString(): kotlin.String = value{{^isString}}.toString(){{/isString}}
companion object {
/**

View File

@ -48,7 +48,7 @@ enum class PetEnum(val value: kotlin.String) {
* This solves a problem when the variable name and its value are different, and ensures that
* the client sends the correct enum values to the server always.
*/
override fun toString(): String = value
override fun toString(): kotlin.String = value
companion object {
/**