Functional types in the receiver position need to be parenthesized
globsterg opened this issue · comments
Describe the bug
Due to Kotlin's precedence rules, to define an extension function on a functional type, you must wrap the functional type with parentheses:
public fun ((Int) -> Int).call(argument: Int): Int = this(argument)
Without the parentheses, the compiler marks this code as erroneous:
public fun (Int) -> Int.call(argument: Int): Int = this(argument)
// Compiler error: "Function declaration must have a name"
When generating documentation for the correct call
definition, Dokka omits the parentheses, producing incorrect syntax.
I do not know if there are other cases in Kotlin where the type must be parenthesized for the syntax to be correct, so I didn't check them. The maintainers are in a better position to do this.
Expected behaviour
I expect the declarations produced by Dokka to be syntactically correct.
To Reproduce
In kotlinx.coroutines's rendered documentation: https://kotlinlang.org/api/kotlinx.coroutines/kotlinx-coroutines-core/kotlinx.coroutines.intrinsics/start-coroutine-cancellable.html