Improve enum exception message (#694)

* Improve enum exception message

It is applicable to enums for proguard reasons, just not with code gen as well

* Update test message
This commit is contained in:
Zac Sweers
2018-09-28 00:24:58 -04:00
committed by GitHub
parent 21a9c56975
commit e0861cca57
2 changed files with 2 additions and 2 deletions

View File

@@ -73,7 +73,7 @@ internal data class TargetType(
when { when {
proto.classKind == Class.Kind.ENUM_CLASS -> { proto.classKind == Class.Kind.ENUM_CLASS -> {
messager.printMessage( messager.printMessage(
ERROR, "@JsonClass can't be applied to $element: must not be an enum class", element) ERROR, "@JsonClass with 'generateAdapter = \"true\"' can't be applied to $element: code gen for enums is not supported or necessary", element)
return null return null
} }
proto.classKind != Class.Kind.CLASS -> { proto.classKind != Class.Kind.CLASS -> {

View File

@@ -153,7 +153,7 @@ class JsonClassCodegenProcessorTest {
val result = call.execute() val result = call.execute()
assertThat(result.exitCode).isEqualTo(ExitCode.COMPILATION_ERROR) assertThat(result.exitCode).isEqualTo(ExitCode.COMPILATION_ERROR)
assertThat(result.systemErr).contains( assertThat(result.systemErr).contains(
"error: @JsonClass can't be applied to KotlinEnum: must not be an enum class") "error: @JsonClass with 'generateAdapter = \"true\"' can't be applied to KotlinEnum: code gen for enums is not supported or necessary")
} }
// Annotation processors don't get called for local classes, so we don't have the opportunity to // Annotation processors don't get called for local classes, so we don't have the opportunity to