pablisco
05/07/2020, 3:17 PMfun doSomething(() -> Unit)
and
fun doSomething(suspend () -> Unit)
I understand that, at least on JVM implementations, this is not possible since both () -> Unit
and suspend () -> Unit
are the “same” because of type erasure. Both are instances of Function0
However, it could be useful when, as an API provider, we want to provide the same api for both without having to use namespacing (like adding a prefix or a postfix) 🙂
Same goes with non coroutine examples like if we want to have overload of operations with generics. Like doSomething(intList: List<Int>)
and doSomething(stringList: List<String>)
If not currently, is there a plans to add this as a language feature? Maybe with namespacing them at compile time.Chilli
05/07/2020, 4:17 PM@JvmName
(or so) annotation to change the name of one of the functions — maybe will work?pablisco
05/07/2020, 4:28 PMpablisco
05/07/2020, 4:31 PMelizarov
05/08/2020, 11:48 AMsuspend
modifier into account and this is currently done on purpose, but might get relaxed in a future. Please, follow this issue: https://youtrack.jetbrains.com/issue/KT-23610pablisco
05/08/2020, 2:59 PMpablisco
05/08/2020, 3:01 PM