magnolia icon indicating copy to clipboard operation
magnolia copied to clipboard

[scala3] Add test for serializable generated type-class

Open RustedBones opened this issue 2 years ago • 4 comments

Scala3 version of magnolia does not generate serializable typeclass when defined inside a non-serializable outer, unlike the scala 2 version. Tested in https://github.com/softwaremill/magnolia/pull/498.

It looks like the summonInline[Typeclass[p]] lambda in the CallByNeed takes a reference on the outer obejct.

RustedBones avatar Nov 13 '23 12:11 RustedBones

@adamw since you reviewed https://github.com/softwaremill/magnolia/pull/498

This new test is only relevant for JVM, and fails for JS and native. The project layout for magnolia looks non standard. I don't know how to add JVM only test.

Would migrating to sbt-corssproject be considered ? I can submit a PR for that.

RustedBones avatar Jan 07 '24 10:01 RustedBones

@RustedBones our projects use https://github.com/sbt/sbt-projectmatrix, in my experience this is the only sane way to maintain projects with both simple & complex cross-platform setups. I think adding the test in scalajvm would do the trick (as opposed to scala), see e.g. here.

adamw avatar Jan 07 '24 11:01 adamw

Ok, let's stick with sbt-projectmatrix. At the moment, there isn't a scala folder. The project defines fake project root and overrides the scalaSource. (btw, this setup does not work well with intelliJ and requires to manually add source to get indexer working). What about standardizing the project layout like this and create a scalajvm source folder in the test project ?

RustedBones avatar Jan 07 '24 15:01 RustedBones

Any take on this one? There is probably a trick to avoid this but I couldn't find any other alternative

RustedBones avatar Mar 18 '24 15:03 RustedBones