Skip to content

Migrate JsonEncoder/Decoder macro to Scala 3 native macro. No more magnolia#929

Open
987Nabil wants to merge 4 commits intozio:series/2.xfrom
987Nabil:scala-3-native-macro
Open

Migrate JsonEncoder/Decoder macro to Scala 3 native macro. No more magnolia#929
987Nabil wants to merge 4 commits intozio:series/2.xfrom
987Nabil:scala-3-native-macro

Conversation

@987Nabil
Copy link
Contributor

  • annotation handling
  • decoders for recursive data structures

@987Nabil
Copy link
Contributor Author

Still needs some refactoring. But it would be nice, if one could approve the workflows.

}
private[zio] object RecordingReader {
object RecordingReader {
def apply(in: OneCharReader): RecordingReader =
Copy link
Contributor Author

@987Nabil 987Nabil Apr 12, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The macro basically inlines the code that calls this apply. Therefore we get a compile time error if it is package private.

@987Nabil 987Nabil changed the title Migrate JsonEncoder macro to Scala 3 native macro. No more magnolia Migrate JsonEncoder/Decoder macro to Scala 3 native macro. No more magnolia Apr 12, 2023
@987Nabil 987Nabil marked this pull request as ready for review April 14, 2023 06:32
@987Nabil 987Nabil requested a review from a team as a code owner April 14, 2023 06:32
@987Nabil
Copy link
Contributor Author

987Nabil commented Apr 14, 2023

I thought one could extract the common macro code to some helper. But this does not seem to work since the imports of the using Quotes are path dependent. So I guess this is ready for review.

@987Nabil 987Nabil force-pushed the scala-3-native-macro branch from b387a71 to 8e40d52 Compare April 14, 2023 06:50
@jdegoes
Copy link
Member

jdegoes commented Apr 25, 2023

@987Nabil Looks great! Can you add some more tests for this under Scala 3 so we can be more assured the derivation is working correctly?

@987Nabil
Copy link
Contributor Author

There are actually a lot of shared tests. I think most cases are covered. But I can take a look if I find something missing.
Do you have something particular in mind?

@plokhotnyuk
Copy link
Contributor

plokhotnyuk commented Apr 25, 2023

@987Nabil Using this benchmark set you can test both correctness and performance of the new way of derivation on ~60 synthetic and real-world JSON samples.

@987Nabil
Copy link
Contributor Author

fyi: The benchmark does not compile. Did not find the time yet to take a deeper look.

@plokhotnyuk plokhotnyuk mentioned this pull request Mar 16, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants

Comments