https://kotlinlang.org logo
Title
s

sitepodmatt

03/25/2019, 2:16 AM
val x: () -> Any? = @Repeated(5) {
            "hi"
        }

        // test if x has annontation
//fail       
        println(x::class.java.annotations.first() as Repeated)
l

LeoColman

03/25/2019, 2:22 AM
I think there's a kotlin way to do it
s

sitepodmatt

03/25/2019, 2:23 AM
x::class.java.getAnnotation(Repeated::class.java) gives a null
happy with java way just need to access it, presuming there is someway
l

LeoColman

03/25/2019, 2:30 AM
I'm not sure how to do that in a lambda tho
Perhaps you can take a look on how it's compiled?
I mean, try to take a look at the bytecode, and see how the hell that class is created
Because it doesn't make sense for me for that to return null
Maybe just
x::class.findAnnotation<Repeated>()
?
s

sitepodmatt

03/25/2019, 6:27 AM
I ended changing my design, i was just trying to hack this in without changing the type signatures etc