How to retrieve the package and class info for an argument function in Scala? -


is there way full package , class info/names function passed argument? imagine following case:

package mypackage  class myclass {   def func(a: int): int = {     *   }    def getpackageinfo(f: int => int): string = {     // return package , class name of f   } } 

in case invoking getpackageinfo(func) somewhere in myclass should return mypackage.myclass.func.

i aware f might anonymous function not belong class, handled check.

i don't mind changing signature of getpackageinfo, long can accept methods , return package , class info.

a normal function can't it, because if write getpackageinfo(func) compiler expands anonymous function: definition it's same getpackageinfo(func _) same getpackageinfo(x => func(x)). information want not stored in f, there no way out.

but can using macro. https://github.com/dwickern/scala-nameof should useful starting point modify: it'll give func instead of mypackage.myclass.func.


Comments

Popular posts from this blog

python Tkinter Capturing keyboard events save as one single string -

android - InAppBilling registering BroadcastReceiver in AndroidManifest -

javascript - Z-index in d3.js -