Is there any way to get access to source code of a lambda function in runtime?
I’m looking for a way to annotate a parameter of a function, so that during compilation, the source code would be stored alongside with the bytecode as metadata.
Use case: In tests, we’re using Hamcrest matchers. I’ve written a utility to transform a matcher using user-supplied function. Usually it’s a very simple lambda, like it.foo
. I would like to print the transforming function if the match failed. I don’t want to describe the functions manually using a separate argument; I’d like it to be automated.
Perhaps there’s some library or compiler plugin out there?