Skip to content
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

Fix macro crash when handling sealed case classes #634

Merged
merged 2 commits into from
Sep 28, 2024

Conversation

nox213
Copy link
Contributor

@nox213 nox213 commented Sep 26, 2024

Fixes #628

Sealed classes can be instantiated directly. Therefore, when generating the typeTag, I included the sealed class itself. This ensures that the macro correctly handles sealed classes without subclasses. To check whether it’s a sealed class and not a trait or abstract class, I used the following condition:

sealedParents.find(_ == tpe.typeSymbol)

Since trait and abstract class cannot be instantiated, I believe this approach works. However, I could also explicitly check that the symbol is not a trait or an abstract class, if needed.

What do you think?

@lihaoyi
Copy link
Member

lihaoyi commented Sep 28, 2024

@nox213 looks great, thanks!

@lihaoyi lihaoyi merged commit 004ed7e into com-lihaoyi:main Sep 28, 2024
8 checks passed
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.

Sealed case class causes compiler crash
2 participants