mirror of
https://github.com/fankes/moshi.git
synced 2025-10-20 00:19:21 +08:00
Fail on sealed classes in KotlinJsonAdapterFactory and code gen (#914)
Resolves #906
This commit is contained in:
@@ -202,6 +202,9 @@ class KotlinJsonAdapterFactory : JsonAdapter.Factory {
|
||||
require(rawTypeKotlin.objectInstance == null) {
|
||||
"Cannot serialize object declaration ${rawType.name}"
|
||||
}
|
||||
require(!rawTypeKotlin.isSealed) {
|
||||
"Cannot reflectively serialize sealed class ${rawType.name}. Please register an adapter."
|
||||
}
|
||||
|
||||
val constructor = rawTypeKotlin.primaryConstructor ?: return null
|
||||
val parametersByName = constructor.parameters.associateBy { it.name }
|
||||
|
Reference in New Issue
Block a user