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


(Douglas Gregor) #1

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
  https://github.com/apple/swift/commit/7c0e087cd514c926d9eaa3082679edff626effc8
  https://github.com/apple/swift/commit/89834f8d5fcce652401ecaeec4addace48cb2fae
  https://github.com/apple/swift/commit/f7407f6a4d2c9b20ef1d2aab6dbaff5f9419aa88
  https://github.com/apple/swift/commit/00313a1e7ec4934a1df12541b9a8f2683f28ed67
  https://github.com/apple/swift/commit/1a830fa541705594bd4b3936de24a20b5b943059
  https://github.com/apple/swift/commit/2a42664129d7e95d182a91858fb268e50373b68b
  https://github.com/apple/swift/commit/37441e1b46cd97d42161455dd712d17ce2ccfe87
  https://github.com/apple/swift/commit/0a359424d7d5bd31c9e7a2f98c15cd9a1fa40328
  https://github.com/apple/swift/commit/9a0241bb3bcdde3531d0ba683e8d6668c50c9f58
  https://github.com/apple/swift/commit/dda35e8c4290d3b941b7ea12b40b87e2590a5332
  https://github.com/apple/swift/commit/5726e7a329128fdf67a31f1c40df8c8db2698aec

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


(Ted Kremenek) #2

Approved for Swift 2.2.

I have created a pull request to track integration:

  https://github.com/apple/swift/pull/1170

···

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
  https://github.com/apple/swift/commit/7c0e087cd514c926d9eaa3082679edff626effc8
  https://github.com/apple/swift/commit/89834f8d5fcce652401ecaeec4addace48cb2fae
  https://github.com/apple/swift/commit/f7407f6a4d2c9b20ef1d2aab6dbaff5f9419aa88
  https://github.com/apple/swift/commit/00313a1e7ec4934a1df12541b9a8f2683f28ed67
  https://github.com/apple/swift/commit/1a830fa541705594bd4b3936de24a20b5b943059
  https://github.com/apple/swift/commit/2a42664129d7e95d182a91858fb268e50373b68b
  https://github.com/apple/swift/commit/37441e1b46cd97d42161455dd712d17ce2ccfe87
  https://github.com/apple/swift/commit/0a359424d7d5bd31c9e7a2f98c15cd9a1fa40328
  https://github.com/apple/swift/commit/9a0241bb3bcdde3531d0ba683e8d6668c50c9f58
  https://github.com/apple/swift/commit/dda35e8c4290d3b941b7ea12b40b87e2590a5332
  https://github.com/apple/swift/commit/5726e7a329128fdf67a31f1c40df8c8db2698aec

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