softwaremill / magnolia

Easy, fast, transparent generic derivation of typeclass instances
https://softwaremill.com/open-source/
Apache License 2.0
754 stars 115 forks source link

[Scala 3] `Macro.anns` throws `IllegalAccessError` when used on parameters with Java types on JDK17+ #493

Closed kyri-petrou closed 8 months ago

kyri-petrou commented 8 months ago

Hi there 👋

There seems to be an issue when using Macro.anns on case class parameters that are Java types on JDK17+ (works fine on JDK11). I created a small reproduction via scatsie here.

The fix to the issue is quite straightforward, and it's to add the following condition to the filterAnnotation method: a.tpe.typeSymbol.owner.fullName != "jdk.internal". Please let me know if you'd like me to create a PR for it and I'll do so

Please note that AFAICT, Macro.paramAnns works as intended, although I thought to let you know since the fix is relatively simple and there might be edge cases where a user will want to extract the param annotations manually as in the repro above

adamw commented 8 months ago

Yes, please do create a PR :)