mirror of
https://github.com/apple/swift.git
synced 2025-12-21 12:14:44 +01:00
Implements the core functionality of SE-0064 / SR-1239, which introduces support for accessing the Objective-C selectors of the getter and setter of an @objc property via #selector(getter: propertyName) and #selector(setter: propertyName). Introduce a bunch of QoI around mistakes using #selector to refer to a property without the "getter:" or "setter:", using Fix-Its to help the user get it right. There is more to do in this area, still, but we have an end-to-end feature working. Much of the implementation and nearly all of the test cases are from Alex Hoppen (@ahoppen). I've done a bit of refactoring, simplified the AST representation, and replaced Alex's custom expression-to-declaration logic with an extension to the constraint solver. The last bit might be short-lived, based on swift-evolution PR280, which narrows the syntax of #selector considerably.
12 lines
387 B
Swift
12 lines
387 B
Swift
import ObjectiveC
|
|
|
|
class OtherObjCClass: NSObject {
|
|
@objc private var privateVar = 1 // expected-note 4{{privateVar' declared here}}
|
|
@objc private(set) var privateSetVar = 2 // expected-note 2{{'privateSetVar' declared here}}
|
|
@objc internal var internalVar = 2
|
|
|
|
internal func internalFunc() {}
|
|
|
|
private func privateFunc() {} // expected-note 2{{'privateFunc' declared here}}
|
|
}
|