We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Swift 5.1 (Xcode 11 beta 6)
md5: d5fe1cc7bb00dd6f51b799cd1652db91
Issue Description:
Normally KeyPath s for @objc properties can be used in utilities like
KeyPath
@objc
class MyClass: NSManagedObject { @NSManaged var stringValue: String? } let keyPath = \MyClass.stringValue print(NSExpression(forKeyPath: keyPath).keyPath) // "stringValue" print(keyPath._kvcKeyPathString) // "stringValue" myObject.observe(keyPath) { object, change in // ... }
However, when using @dynamicMemberLookup accessing this property loses their KVO utility:
@dynamicMemberLookup
@dynamicMemberLookup Expression<O: NSManagedObject> { subscript<V>(dynamicMember member: KeyPath<O, V>) -> String { return NSExpression(forKeyPath: member).keyPath // crash here // return member._kvcKeyPathString // also crashes } } let expression = Expression<MyClass>() print(expression.stringValue) // crash triggered here
The text was updated successfully, but these errors were encountered:
@jckarter, any hypotheses?
Sorry, something went wrong.
It's hitting a fatal error here: https://github.com/apple/swift/blob/master/stdlib/public/Darwin/Foundation/NSObject.swift#L153
Fatal error: Could not extract a String from KeyPath Swift.ReferenceWritableKeyPath<test.MyClass, Swift.Optional<Swift.String>>
@swift-ci create
Comment by John Estropia (JIRA)
Still an issue with Xcode 11/Swift 5.1 release build
This looks like it should've been fixed by #33486 Does it still happen in newer compilers?
No branches or pull requests
Environment
Swift 5.1 (Xcode 11 beta 6)
Additional Detail from JIRA
md5: d5fe1cc7bb00dd6f51b799cd1652db91
Issue Description:
Normally
KeyPath
s for@objc
properties can be used in utilities likeHowever, when using
@dynamicMemberLookup
accessing this property loses their KVO utility:The text was updated successfully, but these errors were encountered: