-
Notifications
You must be signed in to change notification settings - Fork 1
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Improve support for Scala 3 code generation through Scalameta dialects #63
Conversation
Also remove the hack to uppercase enums in #62, as that's not needed anymore. Quasiquotes need the dialect to be fixed at compile time via import. As it runs during compile time, we can't parameterize it with a dialect. This is something we can't do here, as we want to dynamically toggle the output variant, depending on the scala version of the project using the plugin. So to help keeping changes in check, we keep Scala 2 syntax in our quasiquote literals, i.e. we parse q"import io.circe._"), and only apply the dialect during pretty printing, which works for most things where the AST is the same. I.e., imports have the same AST representation.
…12 for this module
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks o.k.
I'm not sure if the toUpperCase
removals change maybe something for the users of the generated code 🤔 - if this is o.k. then 👍
It's the other way around fortunately. We introduced the uppercasing in #63 which isn't part of any release, but would have impacted code with heavy use of enums. I'm reverting that here to reduce the potential impact. |
thanks for the context - makes sense now 🙇 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
👌
This also reverts the hack to use uppercase enums from #62, as it's not needed anymore.
Reasoning for using dialects only during printing
Scalameta uses dialects to express differentes between Scala versions. Quasiquotes need the dialect to be fixed at compile time via import. As it runs during compile time, we can't parameterize it with a dialect dynamically. This is something we can't do here, as we want to dynamically toggle the output variant, depending on the Scala version of the project using the plugin.
On the other hand, we have a lot of code gen blocks using quasiquotes. We also have tons of Scala 2 syntax in our tests.
So to help keeping changes in check, we keep Scala 2 syntax in our quasiquote literals and in tests for now, i.e. we parse
q"import io.circe._")
, and only apply the dialect during pretty printing. This works fine for most things where the AST is the same. I.e. imports have the same AST representation in Scala 2 and 3, even though the syntax is different.