Cannot create anonymous given Codec in Scala3
See original GitHub issueimport com.github.plokhotnyuk.jsoniter_scala.core.*
import com.github.plokhotnyuk.jsoniter_scala.macros.JsonCodecMaker.*
case class DeResult[T](isSucceed: Boolean, data: T, message: String)
case class RootPathFiles(files: List[String])
given JsonValueCodec[DeResult[Option[String]]] = make
given JsonValueCodec[DeResult[RootPathFiles]] = make
Naming Error: xxx\endpoints\TestEndpoint.scala:16:8
[error] 16 | given JsonValueCodec[DeResult[RootPathFiles]] = make
[error] | ^
[error] |Double definition:
[error] |final lazy given val given_JsonValueCodec_DeResult:
[error] | com.github.plokhotnyuk.jsoniter_scala.core.JsonValueCodec[
[error] | de.video.test.model.DeResult[Option[String]]
[error] | ] in object TestEndpoint at line 15 and
[error] |final lazy given val given_JsonValueCodec_DeResult:
[error] | com.github.plokhotnyuk.jsoniter_scala.core.JsonValueCodec[
[error] | de.video.test.model.DeResult[de.video.test.model.RootPathFiles]
[error] | ] in object TestEndpoint at line 16
Sine the same case class with different type parameters, jsoniter use the same given var name.
A workaround is
given jsonValueCodecImplicit1: JsonValueCodec[DeResult[Option[String]]] = make
given jsonValueCodecImplicit2: JsonValueCodec[DeResult[RootPathFiles]] = make
Issue Analytics
- State:
- Created a year ago
- Comments:5 (5 by maintainers)
Top Results From Across the Web
Scala 3 enums have limited customisation support #2336
If the enum has no fields the implementations are anonymous, however if the enum has fields then subclasses are created. As of v1.0.1,...
Read more >Scala 3 macro: generic type from class - Stack Overflow
So I need a runtime compile feature. Code: object CodecMacro { import scala.quoted.staging.* given Compiler = Compiler.make(getClass.
Read more >lampepfl/dotty - Gitter
I have no idea if the code I wrote is really dangerous or if there is a workaround to make dotc compile it....
Read more >Anonymous Functions | Scala 3 — Book
For example, given a list like this: Scala 2 and 3. val ints = List(1, 2, 3). You can create a new list...
Read more >Can't find a codec for class com.mongodb.client.model ...
It may not make sense for mongo - I am just trying to use the aggregate function..
Read more >
Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free
Top Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Yes, it’s the same problem. Now use
and
It’s more suitable for jsoniter’s style since that jsoniter not support nested Codec count.
I see. Usually, when I need a
Encoder[DeResult[List[Model1]]]
, actually I just needEncoder[DeResult[T]]
,Encoder[List[T]]
andEncoder[Model1]
. It does not seem to be a urgent issue in Scala3.