question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Add support for type parameters in annotations

See original GitHub issue

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:

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:closed
  • Created 3 years ago
  • Comments:6 (3 by maintainers)

github_iconTop GitHub Comments

1reaction
joroKr21commented, Apr 27, 2021

At least there is a step in that direction: #1019 Next would be, write a scalafix rule to replace Lazy and Strict with by-name implicits in the source code.

1reaction
joroKr21commented, Apr 27, 2021

@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. 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.

Read more comments on GitHub >

github_iconTop 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 >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found