Add support for type parameters in annotations
See original GitHub issueFollow 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:
case class MyAnnotation[T](t: T) extends scala.annotation.StaticAnnotation
The out type of Annotations
and TypeAnnotations
would have the complete “reference” to type T
.
Issue Analytics
- State:
- Created 3 years ago
- Comments:6 (3 by maintainers)
Top Results From Across the Web
Annotation attributes with type parameters - Stack Overflow
One approach is to allow type parameters for a type: <X>Map<X,X> . ... We need to change/add a lot of things to make...
Read more >Support annotations on class type parameters ...
Suppose we wanted to annotate it with an annotation, let's call it @Immutable , that can be used to mark conceptually immutable classes...
Read more >typing — Support for type hints — Python 3.11.1 documentation
Subtypes are accepted as arguments. New features are frequently added to the typing module. The typing_extensions package provides backports of these new ...
Read more >Making the Most of Java's Metadata, Part 2: Custom Annotations
To provide your @Unfinished annotation type with its description, owner, and priority you'll need to add parameters to the annotation declaration.
Read more >TYPE_USE annotations in TYPE_PARAMETER locations ...
If so, then the purpose of TYPE_PARAMETER seems to be cases in which you want only type parameters to be annotated, not type...
Read more >
Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free
Top Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
At least there is a step in that direction: #1019 Next would be, write a scalafix rule to replace
Lazy
andStrict
with by-name implicits in the source code.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. There is Shapeless 3 which works only with Scala 3 on the shapeless-3 branch. I don’t know much about it yet, so I can’t say what it offers in terms of annotations. Separately from that we have an issue to port shapeless 2 in some form to Scala 3: #1043 But nobody is working on that at the moment.