Skip to content

Port macroRWAll to Scala2 #459

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

Closed
wants to merge 12 commits into from
Closed

Port macroRWAll to Scala2 #459

wants to merge 12 commits into from

Conversation

lihaoyi
Copy link
Member

@lihaoyi lihaoyi commented Mar 11, 2023

Attempts to port #453 to Scala 2

Doesn't quite work because the superTypeWriter currently causes diverging implicit expansions

@lihaoyi lihaoyi changed the title Enums3 scala2 Port macroRWAll to Scala2 Mar 11, 2023
lihaoyi added a commit that referenced this pull request Mar 20, 2023
…Writer/superTypeReader (#471)

Fixes #468

The basic problem is that with `enum A: case B`, Calling `implicit def
rw: RW[A] = macroR` will end up looking for a `R[B]`, which will trigger
`superTypeReader[B, A]`, which picks up the `rw` we are defining and
becoming an infinite recursion/loop.

The fix here is to ensure that when calling
`macroR[T]`/`macroW[T]`/`macroRW[T]`, that `superTypeReader` and
`superTypeWriter` do not trigger on type `[_, T]`. We can do that by
requiring that they take a `NotGiven[CurrentlyDeriving[T]]`, and
providing an implicit `CurrentlyDeriving[T]` in the
`macroR`/`macroW`/`macroRW` bodies.

Added some `compileError` tests to ensure these raise implicit not found
errors as expected

While `superTypeWriter`/`superTypeReader` had their signatures changed,
the fact that they are `inline` means there are no binary compatibility
concerns

This is only necessary for Scala 3, since Scala 2 doesn't have
`superTypeWriter`/`superTypeReader` in the first place due to diverging
implicit issues (see #459)
@lihaoyi lihaoyi closed this Jul 9, 2023
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.

1 participant