Paul Woitaschek

09/06/2018, 9:59 AM


09/06/2018, 10:01 AM
Ah, that makes sense. I'm not aware of this being requested, but that seems like a good thing to have.
It looks like this is implemented in Kotlin 1.3-M2 as I just tried it in IntelliJ with that version.
Never mind, the named argument at the callsite is what isn't allowed.
The problem is probably that the alias and type are interchangeable, so having a
functionality might require significant change.
In kotlin 1.3, you can try this if you don't need inlining of the function itself:
typealias ChangePortionCountValue = (increase: Boolean) -> Unit
inline class ChangePortionCount(val value: ChangePortionCountValue) {
    operator fun invoke(increase: Boolean) = value(increase)
fun something(changePortionCount: ChangePortionCount) {
    changePortionCount(increase = true)
Though, at that point, you can also just use an interface, actually. haha.