Open Octogonapus opened 5 years ago
The annotation processor generates invalid code for sealed classes.
This code:
@json sealed class LinkType { object Rotary : LinkType() object Prismatic : LinkType() companion object }
Generates this:
fun LinkType.toJson(): Json = JsObject(mapOf()) fun Json.Companion.toLinkType(value: Json): Either<DecodingError, LinkType> = Either.applicative<DecodingError>().map( , { -> LinkType() }).fix() fun LinkType.Companion.encoder() = object : Encoder<LinkType> { override fun LinkType.encode(): Json = this.toJson() } fun LinkType.Companion.decoder() = object : Decoder<LinkType> { override fun decode(value: Json): Either<DecodingError, LinkType> = Json.toLinkType(value) }
Apart from the issue with the call to map(), it's not possible to construct a LinkType because it is a sealed class.
map()
LinkType
The annotation processor generates invalid code for sealed classes.
This code:
Generates this:
Apart from the issue with the call to
map()
, it's not possible to construct aLinkType
because it is a sealed class.