Skip to content
New issue

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

[SR-9961] Incorrect diagnostic when using read-only property with ReferenceWritableKeyPath (on in Swift >= 5 mode). #52365

Closed
xedin opened this issue Feb 20, 2019 · 0 comments
Labels
bug A deviation from expected or documented behavior. Also: expected but undesirable behavior. diagnostics QoI Bug: Diagnostics Quality of Implementation good first issue Good for newcomers

Comments

@xedin
Copy link
Member

xedin commented Feb 20, 2019

Previous ID SR-9961
Radar None
Original Reporter @xedin
Type Bug
Status Closed
Resolution Duplicate
Additional Detail from JIRA
Votes 0
Component/s
Labels Bug, DiagnosticsQoI, StarterBug
Assignee None
Priority Medium

md5: 86a5a91e73548feac9b85cee2928b29b

duplicates:

  • SR-9958 Incorrect error message for non-matching signatures with KeyPaths

Issue Description:

Based on https://forums.swift.org/t/new-ambiguity-with-keypaths-in-swift-5/20668

import Cocoa

class MsPiggy: NSObject {
    let k = Kermit()
    
    func party() {
        // Here I get `Type of expression is ambiguous without more context`
        // but only with the Swift 5 compiler. In Swift 4.2 mode everything is fine.
        k.a(\.color) { v in }
    }
}

class Kermit: NSObject {
    // If I remove the `private(set)` here, even Swift 5 is happily compiling this
    @objc dynamic private(set) var color: NSColor!
}

extension NSObjectProtocol where Self: NSObject {
    func a<Value>(_ keyPath: ReferenceWritableKeyPath<Self, Value>, onChange: @escaping (Value) -> ()) {}
    func a<Value>(_ keyPath: ReferenceWritableKeyPath<Self, Value>, onChange: @escaping (Self, Value) -> ()) {}
}
@swift-ci swift-ci transferred this issue from apple/swift-issues Apr 25, 2022
This issue was closed.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug A deviation from expected or documented behavior. Also: expected but undesirable behavior. diagnostics QoI Bug: Diagnostics Quality of Implementation good first issue Good for newcomers
Projects
None yet
Development

No branches or pull requests

1 participant