KotlinJsonAdapter shouldn't convert enums.

Closes: https://github.com/square/moshi/issues/284
This commit is contained in:
jwilson
2017-04-21 09:41:41 -05:00
parent d95dd07c56
commit cd1542363d
2 changed files with 19 additions and 7 deletions

View File

@@ -156,10 +156,9 @@ object KotlinJsonAdapterFactory : JsonAdapter.Factory {
if (!annotations.isEmpty()) return null
val rawType = Types.getRawType(type)
val platformType = ClassJsonAdapter.isPlatformType(rawType)
if (platformType) return null
if (rawType.isEnum) return null
if (!rawType.isAnnotationPresent(KOTLIN_METADATA)) return null
if (ClassJsonAdapter.isPlatformType(rawType)) return null
val constructor = rawType.kotlin.primaryConstructor ?: return null
val parametersByName = constructor.parameters.associateBy { it.name }