Closed little-inferno closed 2 months ago
Couldn't reproduce in Scastie:
Then the reproduction from https://github.com/little-inferno/chimney-error worked.
However, commenting out
//ThisBuild / scalacOptions += "-Ymacro-annotations"
make the code work again. I am not sure what is the cause, but presence of "-Ymacro-annotations"
changes what macros sees internally, I suspect that we might have a workaround for such cases which did not survive the rewrite as it's difficult to have a regression test for something as unpredictable as compiler flag changing the data available to the macro. I might take a look at this somewhere in the next week if I'll have the time.
Yes, it seems that using -Ymacro-annotations
change decoded name from
apply$default$idx
to
<init>$default$idx
And this matching give an error https://github.com/scalalandio/chimney/blob/2643676b3e89469038c2ec7e354411fc8b9b3319/chimney-macro-commons/src/main/scala-2/io/scalaland/chimney/internal/compiletime/datatypes/ProductTypesPlatform.scala#L129-L139
I wrote dirty quickfix and it fix compilation errors in https://github.com/little-inferno/chimney-error
I have something local, but I'd need to add regression tests to make sure it works and would keep working.
My local fix was quite similar to your - I'd add a test for default value in a class which is not case class
, and maybe something with -Ymacro-annotations
. I suspect that missing tpe.typeSymbol.typeSingature
was the issue, since there was an unfixed bug in Scala 2 macros when sometimes type symbol is not initialized until this method is called (even if it's completely not needed). But I haven't tested this PR at all.
As far as I tested the fix I merged worked. I tested with local snapshot, once https://github.com/scalalandio/chimney/actions/runs/9761346064/job/26942175116 passed you might check as well with a Sonatype OSS shapshots.
Great, there are no more errors with the default parameters 🎉
Released in 1.3.0
Checklist
TransformerF
s) orunsafeOption
flagsDescribe the bug
Compilation fail on new Chimney version if case class parameter have annotation and parameters have default value
Reproduction
I created a repository to reproduce: https://github.com/little-inferno/chimney-error
Project chimney075 and chimney120 contain the same code but use a different version of Chimney, the first one works, the second one doesn’t
Expected behavior
I expected that Chimney can transform case classes with annotated parameters
Actual behavior
Use chimney 0.7.5 - success
Use chimney 1.2.0 -
Which Chimney version do you use
Chimney <= 0.7.5 works great
Chimney >= 0.8.0 give an error
Which platform do you use
If you checked JVM
Temurin-17.0.11+9