https://kotlinlang.org logo
#getting-started
Title
# getting-started
j

Jon Senchyna

03/01/2023, 9:13 PM
Is there a way to combine annotations that don't have
@Inherited
on them?
Is there a way to create an annotation that applies
@Suppress(...)
to its target, in addition to other things? We often use `@Nested inner class
given some criteria
{...}` to group together test cases in our JUnit unit tests, and its annoying to have to add
@Suppress("ClassName")
every time (plus many teammates forget, so we have warnings popping up all over our tests). Ideally, I'd like to create an annotation that bundles
@Nested
with
@Suppress("ClassName")
that we then use for all of these (we'll call it
@Describe
as an example). I can annotate my
Describe
annotation class with
@Nested
and have that propagate through to whatever I annotate with
@Describe
, but
@Suppress("ClassName")
appears to just suppress warning on the naming of my annotation class and does not allow me to suppress warnings on the name of the annotated inner class.
24 Views