Hi :wave: what use case does <this error> report o...
# compiler
j
Hi 👋 what use case does this error report on? Seems to be related to annotated inline lambdas with annotations using non source retention (any annotations that survive until the output binaries), maybe related to closure capturing but not 100% sure.
Looking twice seems logical that you can't annotate with retention != SOURCE since inline lambdas are effectively inlined into their caller's body at compile time, so they'll not be stored / retained anywhere and therefore there's nothing to annotate on the output binaries.
Still I'm not able to reproduce this error with a minimal sample code. I'd expect this to fail following that reasoning:
Copy code
@Retention(AnnotationRetention.BINARY)
@Target(
  AnnotationTarget.FUNCTION,
  AnnotationTarget.TYPE
)
annotation class SomeAnnotation

inline fun a(f: @SomeAnnotation (String) -> Int): Int = f("Hello world")
Got it, needed to annotate on call site to trigger the error: i.e:
Copy code
@Target(AnnotationTarget.FUNCTION)
annotation class FunAnn

inline fun myFun(a: Int, f: (Int) -> String): String = f(a)

fun main() {
  myFun(1) @FunAnn { it.toString() }
}