In Kotlin we can't create class which implements 2 lambdas with different signature, like this:
class Test<T> : (T) -> Unit, () -> T {
...
}
which gives following error:
Type parameter R of 'Function' has inconsistent values: Unit, T
I understand the reason why it happens: all lambdas are FunctionN
interfaces and all FunctionN
interfaces extend some marker interface called Function
which can't be invoked. But also last one is the root cause of generics conflict and error mentioned above.
My question probably to Kotlin team: is there any reason why all FunctionN
extend Function
interface? Maybe some internal/bytecode stuff which isn't obvious for us, but makes some tricky optimization for performance underneath.