I found out that the String returned by #function literal in Swift 3.1 is... weird. Here:
class FunctionLiteralTest {
func weirdo() -> String {
return #function
}
func weirdo(parameter: Int) -> String {
return #function
}
func weirdo(_ parameter: Int) -> String {
return #function
}
func weirdo(_ parameter: Int, _ anotherParameter: Int) -> String {
return #function
}
}
let functionLiteralTest = FunctionLiteralTest()
functionLiteralTest.weirdo() // returns "weirdo()"
functionLiteralTest.weirdo(parameter: 1) // returns "weirdo(parameter:)"
functionLiteralTest.weirdo(1) // returns "weirdo"
functionLiteralTest.weirdo(1, 2) // returns "weirdo"
Parentheses are skipped entirely when all parameters are unlabeled. I would quite understand that if #function returned function name without parentheses for functions without any parameters too.
Is that justified behavior or a bug?