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

Added isEnum field to SealedTrait #332

Merged
merged 2 commits into from
Aug 10, 2021
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion src/core/interface.scala
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,8 @@ case class SealedTrait[Typeclass[_], Type]
(typeInfo: TypeInfo,
subtypes: IArray[SealedTrait.Subtype[Typeclass, Type, _]],
annotations: IArray[Any],
typeAnnotations: IArray[Any]) extends Serializable:
typeAnnotations: IArray[Any],
isEnum: Boolean = false) extends Serializable:
Copy link
Collaborator

Choose a reason for hiding this comment

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

The SealedTrait name can be misleading, it can represent both the sealed hierarchies of sealed traits as well as enums. To implement this issue, a small macro would be needed similar to isObject here:

def isObject[T: Type](using Quotes): Expr[Boolean] =

All flags in Quotes API can be found here.
This macro should be used in magnolia.scala when creating SealedTrait instances.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Thanks for help


type Subtype[S] = SealedTrait.SubtypeValue[Typeclass, Type, S]

Expand Down