phobos icon indicating copy to clipboard operation
phobos copied to clipboard

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

Open steffenlaursen opened this issue 1 year ago • 1 comments

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 [33mvalue[0m [35mdecodingResult[0m/[33mmethod[0m [35mgo[0m/[33mmethod[0m [35mdecodeAsElement[0m/[33mclass[0m [35mTDecoder[0m/[33mmethod[0m [35minstance[0m/[33manonymous class[0m [35mObject[0m[33m with [0m[35mphobos.derivation.LazySummon[0m {...}/[33mvalue[0m [35mTuple_this[0m/[33mvalue[0m [35mlazyTCs[0m/[33mvalue[0m [35mchildInfos[0m/[33mgetter[0m [35mGoodOrBadDecoder[0m/[33mmethod[0m [35mrun[0m/[33mobject[0m [35mPhobosTest[0m/[33mpackage[0m [35m<empty>[0m/[33mpackage[0m [35m<root>[0m to `this` of [33mobject[0m [35mGoodOrBad[0m;
[33manonymous class[0m [35mObject[0m[33m with [0m[35mphobos.derivation.LazySummon[0m {...} 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

steffenlaursen avatar Oct 09 '24 11:10 steffenlaursen

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

valentiay avatar Oct 13 '24 19:10 valentiay

Hi! Closing this issue for now, as I failed to reproduce it. Feel free to reopen it, if it is still relevant

valentiay avatar Sep 01 '25 20:09 valentiay