[Pitch] @completionHandlerAsync attribute

(To clarify, I'm not suggesting we should use string literals)

It's probably possible to express a getter without a string literal. Also, if we type check it, we should be able to infer that it's a getter because we know value is var or func.

(One interesting fact about @available(renamed:) is that it doesn't type check the new name. i.e. @available(*, deprecated, renamed: "foobar()") is not an error and emits fix-it even without actual foobar declaration.)

I guess another reason of using a string literal was to have a common logic to handle objc __attribute__((swift_name("..."))) attribute and/or apinotes. But I'm not sure. Perhaps @jrose knows the history?

#selector uses getter:/setter: prefix. But @completionHandlerAsync(getter:valueName) is not ideal as it's confusable with a attribute argument label...

@derivative(of: ) uses postfix .get/.set?

Related discussion for syntax of referencing getter/setters:
https://github.com/apple/swift-evolution/blob/main/proposals/0021-generalized-naming.md
https://forums.swift.org/t/proposal-expose-getter-setters-in-the-same-way-as-regular-methods/501
https://forums.swift.org/t/review-se-0044-import-as-member/1805/5

1 Like