-
Notifications
You must be signed in to change notification settings - Fork 534
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
Add support for type parameters in annotations #1051
Comments
Moreover, what about generalizing Annotations to return all annotations instead of just one annotation type case class HelloWorld(
field1: String @A11[T111, T112, ..., T11n] @A12[T121, T122, ..., T12n] ... @A1m[T1m1, T1m2, ..., T1mn],
field2: String @A21[T211, T212, ..., T21n] @A22[T221, T222, ..., T22n] ... @A2m[T2m1, T2m2, ..., T2mn],
...,
fieldk: String @Ak1[Tk11, Tk12, ..., Tk1n] @Ak2[Tk21, Tk22, ..., Tk2n] ... @Akm[Tkm1, Tkm2, ..., Tkmn],
) Would be nice to have a single macro to extract in one pass all annotations, no? The trait would look like the following: trait AllAnnotations[T] extends DepFn0 with Serializable {
// no more type A
type Out <: HList
} For the example above, the (A11[T111, T112, ..., T11n] :: A12[T121, T122, ..., T12n] :: ... :: A1m[T1m1, T1m2, ..., T1mn] :: HNil) ::
(A21[T211, T212, ..., T21n] :: A22[T221, T222, ..., T22n] :: ... :: A2m[T2m1, T2m2, ..., T2mn] :: HNil) ::
... ::
(Ak1[Tk11, Tk12, ..., Tk1n] :: Ak2[Tk21, Tk22, ..., Tk2n] :: ... :: Akm[Tkm1, Tkm2, ..., Tkmn] :: HNil) :: HNil |
AFAIC, I think it would be nice to have. |
I have a working prototype. Will try to submit a PR in the coming days. |
Add support to extract all variable or type annotations (issue #1051)
@joroKr21 just wondering, is this going to work with Scala 3? |
The Scala 3 story is a bit messy for shapeless because it uses a lot of macros. This particular implementation won't work on Scala 3. |
At least there is a step in that direction: #1019 |
Add support to extract all variable or type annotations (issue #1051)
Follow up on issue #922 and pull request #925. I would like to add support for type parameters in annotations, both variable and type annotations. For example, define an annotation such as:
The out type of
Annotations
andTypeAnnotations
would have the complete "reference" to typeT
.The text was updated successfully, but these errors were encountered: