valentiay / phobos

Efficient and expressive XML data-binding library for Scala
Apache License 2.0
20 stars 5 forks source link

Enums with Encoder/Decoder deriving fails to compile on Scala 3.5.1 #30

Open steffenlaursen opened 1 month ago

steffenlaursen commented 1 month ago

Compiler error:

scala: ## Exception when compiling 2 sources to C:\repos\STLBW\XmlCodecExperiments\target\scala-3.5.1\classes
java.lang.AssertionError: assertion failed: failure to construct path from value decodingResult/method go/method decodeAsElement/class TDecoder/method instance/anonymous class Object with phobos.derivation.LazySummon {...}/value Tuple_this/value lazyTCs/value childInfos/getter GoodOrBadDecoder/method run/object PhobosTest/package <empty>/package <root> to `this` of object GoodOrBad;
anonymous class Object with phobos.derivation.LazySummon {...} does not have an outer accessor
scala.runtime.Scala3RunTime$.assertFailed(Scala3RunTime.scala:8)
dotty.tools.dotc.transform.ExplicitOuter$OuterOps$.loop$1(ExplicitOuter.scala:465)
dotty.tools.dotc.transform.ExplicitOuter$OuterOps$.path$extension(ExplicitOuter.scala:469)
dotty.tools.dotc.transform.Erasure$Typer.typedThis(Erasure.scala:811)
dotty.tools.dotc.typer.Typer.typedUnnamed$1(Typer.scala:3415)
dotty.tools.dotc.typer.Typer.typedUnadapted(Typer.scala:3499)

Sample code:

    enum GoodOrBad :
      case Good
      case Bad

    given goodOrBadEncoder: ElementEncoder[GoodOrBad] = deriveElementEncoder
    given goodOrBadDecoder: ElementDecoder[GoodOrBad] = deriveElementDecoder
valentiay commented 1 month ago

Hi! Could you please provide a full code sample (including build configuration) and info about phobos and java versions? Same as for #29, I failed to reproduce it