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-8343] Protocol Ambiguity with Swift 4.2 (Xcode 10b4) #50871

Closed
swift-ci opened this issue Jul 22, 2018 · 5 comments
Closed

[SR-8343] Protocol Ambiguity with Swift 4.2 (Xcode 10b4) #50871

swift-ci opened this issue Jul 22, 2018 · 5 comments
Labels
bug A deviation from expected or documented behavior. Also: expected but undesirable behavior. compiler The Swift compiler in itself regression swift 4.2

Comments

@swift-ci
Copy link
Collaborator

Previous ID SR-8343
Radar rdar://problem/42501603
Original Reporter freak4pc (JIRA User)
Type Bug
Status Resolved
Resolution Duplicate

Attachment: Download

Environment

Xcode 10b4
macOS Mojave Developer Beta

Additional Detail from JIRA
Votes 0
Component/s Compiler
Labels Bug, 4.2Regression
Assignee None
Priority Medium

md5: dab0371482dd1ba81c35be440be213f5

duplicates:

  • SR-7940 "Ambiguous use" in Xcode 10, Swift 4.2

Issue Description:

The following piece of code builds correctly on Xcode 9.4.x, but fails to build on Xcode 10.
Also attached contained project so it's easy to look into.

import UIKit

protocol SomeProtocol {
    var navController: UINavigationController? { get }
}

public class BaseViewController: UIViewController {
    var navController: UINavigationController? {
        return navigationController
    }
}

class ViewController: BaseViewController {
    override func viewDidLoad() {
        super.viewDidLoad()
    }
}

extension SomeProtocol where Self: ViewController {
    func doStuff() {
        let x: () -> Void = { [weak self] in
            // Ambiguous use of 'navController'
            // Used to build fine on Xcode 9.4 GM, doesn't build since
            // Xcode 10b1 (and not on the latest b4).
            guard let nav = self?.navController else { return }
        }
    }
}

Screenshot:

Thanks for your assistance!

@belkadan
Copy link
Contributor

Workaround:

let baseSelf: BaseViewController? = self
guard let nav = baseSelf?.navController else { return }

@swift-ci create

@swift-ci
Copy link
Collaborator Author

Comment by Shai Mishali (JIRA)

Thanks @belkadan, That's what I did 🙂
Appreciate the prompt response.

@hamishknight
Copy link
Collaborator

I believe this is a dupe of https://bugs.swift.org/browse/SR-7940 and we consider it to be working as intended, as it's ambiguous whether you're referring to the protocol requirement or the class implementation (as Slava says in the linked bug report, we already had this behaviour for methods).

@hamishknight
Copy link
Collaborator

And also https://bugs.swift.org/browse/SR-7425

@swift-ci
Copy link
Collaborator Author

Comment by Shai Mishali (JIRA)

SR-7940 seems to clarify this is intended behavior, but that is indeed a strange regression from my angle. As long as you don't consider it a bug, I'm fine closing it down.

@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. compiler The Swift compiler in itself regression swift 4.2
Projects
None yet
Development

No branches or pull requests

4 participants