Hello! I would like to take advantage of the `call...
# multiplatform
d
Hello! I would like to take advantage of the
callAsFunction
operator in Swift like the
operator fun invoke
function in Kotlin. I tested its feasibility and by using
@ObjCName("callAsFunction")
I’m able to achieve that behavior. Is there a way to declare an annotation that applies the ObjCName renaming to the annotated function? I thought that this would have worked but it didn’t…
Copy code
@OptIn(ExperimentalObjCName::class)
@ObjCName("callAsFunction")
annotation class SwiftCallAsFunction
my goal is to avoid to repeat the
"callAsFunction"
string everywhere is needed. I thought about using a constant but I would like to understand if there are other ways thanks!
🍿 1
1
e
No it won't work. You need a compiler plugin. But keep it simple.
j
Maybe it's something that the folks at #touchlab-tools can help?
d
I’ll try to post it also in that channel, thanks