Considering the following example:
interface A {
fun foo(n: Int): String
}
fun applyPrefix(prefix: String): A = object : A {
override fun foo(n: Int) = prefix + n
}
Currently it’s not possible define applyPrefix in a more compact way (as reported in KT-7770):
fun applyPrefix(prefix: String): A = { n -> prefix + n } // syntax error
However now you can use the type aliases, so:
typealias A = (Int) -> String
fun applyPrefix(prefix: String): A = { n -> prefix + n }
This is great, but there is a little problem: it’s not the same thing from a Java perspective.
If you are using this library in a Java project, you see that applyPrefix returns a Function1<Integer, String>, so you cannot benefit from functional interfaces (for example, to search all usages of A functors).
Obviously the java project could define an interface like A converting Function1 properly, but this could be frustracting in a wide project.
In your opinion how this “problem” could be addressed?