[Swift 2.2] Request to merge SE-0022: #selector expression

Hi Ted,

I’d like to pull the implementation of the Objective-C #selector expression into the Swift 2.2 branch:

  swift-evolution/0022-objc-selectors.md at master · apple/swift-evolution · GitHub

The actual implementation is in a number of commits that can be cherry-picked:

  https://github.com/apple/swift/commit/dccf3155f1fe5400df0c9b51f21a3b8f7fa09b9c
  https://github.com/apple/swift/commit/7c0e087cd514c926d9eaa3082679edff626effc8
  [ObjC IRGen] Clean up emission of Objective-C selectors. · apple/swift@89834f8 · GitHub
  [SILGen] SE-0022: emit SIL for #selector expressions. · apple/swift@f7407f6 · GitHub
  test/IRGen/objc_selector.sil has an uninteresting 64-bit dependency. · apple/swift@00313a1 · GitHub
  https://github.com/apple/swift/commit/1a830fa541705594bd4b3936de24a20b5b943059
  Use #selector in StdlibUnitTest's Foundation extras · apple/swift@2a42664 · GitHub
  SE-0022: Code completion for #selector. · apple/swift@37441e1 · GitHub
  SE-0022: Add a changelog entry for #selector. It's done. · apple/swift@0a35942 · GitHub
  https://github.com/apple/swift/commit/9a0241bb3bcdde3531d0ba683e8d6668c50c9f58
  https://github.com/apple/swift/commit/dda35e8c4290d3b941b7ea12b40b87e2590a5332
  [Sema] Eliminate a foolish little infinite loop I introduced. · apple/swift@5726e7a · GitHub

This proposal contains both a new feature (the #selector expression) and the deprecation of an existing feature (treating a string literal as a Selector). Our intent is to use 2.2 to start migrating existing clients over to the new syntax, which will become far more important with The Grand Renaming in Swift 3.

There is risk here, of course: I changed the way we emit Objective-C selector references a bit, and the Fix-It code for translating uses of string-literals-as-selectors is non-trivial and makes use of another new feature (SE-0021, compound names). That said, I’m not overly concerned about new problems being introduced by this code. I’d love to see better code completion for compound names, but haven’t figured out a good way to do it yet.

  - Doug

Approved for Swift 2.2.

I have created a pull request to track integration:

  [Swift 2.2] SE-0022 by tkremenek · Pull Request #1170 · apple/swift · GitHub

···

On Feb 2, 2016, at 9:06 AM, Douglas Gregor <dgregor@apple.com> wrote:

Hi Ted,

I’d like to pull the implementation of the Objective-C selector expression into the Swift 2.2 branch:

  https://github.com/apple/swift-evolution/blob/master/proposals/0022-objc-selectors.md

The actual implementation is in a number of commits that can be cherry-picked:

  https://github.com/apple/swift/commit/dccf3155f1fe5400df0c9b51f21a3b8f7fa09b9c
  [SIL] Extend the string_literal instruction with an 'objc_selector' e… · apple/swift@7c0e087 · GitHub
  [ObjC IRGen] Clean up emission of Objective-C selectors. · apple/swift@89834f8 · GitHub
  [SILGen] SE-0022: emit SIL for #selector expressions. · apple/swift@f7407f6 · GitHub
  test/IRGen/objc_selector.sil has an uninteresting 64-bit dependency. · apple/swift@00313a1 · GitHub
  SE-0022: Deprecate string-literal-as-selector in favor of #selector. · apple/swift@1a830fa · GitHub
  Use #selector in StdlibUnitTest's Foundation extras · apple/swift@2a42664 · GitHub
  SE-0022: Code completion for #selector. · apple/swift@37441e1 · GitHub
  SE-0022: Add a changelog entry for #selector. It's done. · apple/swift@0a35942 · GitHub
  SE-0022: Address Jordan's review comments about #selector. · apple/swift@9a0241b · GitHub
  [CHANGELOG] Markdown fixes to the #selector comment. · apple/swift@dda35e8 · GitHub
  [Sema] Eliminate a foolish little infinite loop I introduced. · apple/swift@5726e7a · GitHub

This proposal contains both a new feature (the selector expression) and the deprecation of an existing feature (treating a string literal as a Selector). Our intent is to use 2.2 to start migrating existing clients over to the new syntax, which will become far more important with The Grand Renaming in Swift 3.

There is risk here, of course: I changed the way we emit Objective-C selector references a bit, and the Fix-It code for translating uses of string-literals-as-selectors is non-trivial and makes use of another new feature (SE-0021, compound names). That said, I’m not overly concerned about new problems being introduced by this code. I’d love to see better code completion for compound names, but haven’t figured out a good way to do it yet.

  - Doug