Skip to content

Use opaque type instead of sealed trait for Scala 3 #587

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
armanbilge opened this issue Sep 27, 2021 · 4 comments · Fixed by #592
Closed

Use opaque type instead of sealed trait for Scala 3 #587

armanbilge opened this issue Sep 27, 2021 · 4 comments · Fixed by #592
Assignees
Milestone

Comments

@armanbilge
Copy link
Member

See #579 (comment).

@armanbilge armanbilge added this to the v2.0.0 milestone Sep 27, 2021
@armanbilge armanbilge changed the title Use opaque types instead of sealed traits for Scala 3 Use opaque type instead of sealed trait for Scala 3 Sep 27, 2021
@armanbilge
Copy link
Member Author

@sjrd I looked into this a bit and doing this seems complicated by the fact that a sealed trait must be defined in the same file as its companion object (I don't think opaque types have the same rules).

So the only way I can see to do this would be to extract the companion object methods into a private[dom] trait that can be shared source between 2/3, and then extending it from the companion objects defined in both Scala 2 and Scala 3 sources seperately.

Seems a bit annoying but definitely do-able. Is there a better strategy?

@armanbilge armanbilge self-assigned this Oct 10, 2021
@sjrd
Copy link
Member

sjrd commented Oct 10, 2021

The companion objects of those sealed traits should have few members, that are basically constants. My idea was simply to copy-paste them.

@armanbilge
Copy link
Member Author

Right, that works too 😆 any preference either way?

Do you mind if I try and wrap this up?

@sjrd
Copy link
Member

sjrd commented Oct 10, 2021

The copy-paste makes for a better user-facing API, so I would go with that.

@armanbilge armanbilge linked a pull request Oct 10, 2021 that will close this issue
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants