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-8215] warning: Swift runtime does not yet support dynamically querying conditional conformance #50747

Closed
swift-ci opened this issue Jul 10, 2018 · 1 comment
Labels
bug A deviation from expected or documented behavior. Also: expected but undesirable behavior.

Comments

@swift-ci
Copy link
Collaborator

Previous ID SR-8215
Radar None
Original Reporter grifis (JIRA User)
Type Bug
Status Resolved
Resolution Invalid
Environment

Xcode Version 9.4 (9F1027a), Swift 4.1

Additional Detail from JIRA
Votes 0
Component/s
Labels Bug
Assignee None
Priority Medium

md5: a2ce575ccd4712e1074ba678d4b9d18f

is duplicated by:

  • SR-8666 Segmentation fault: 11 (related to dynamically querying conditional conformance?)

Issue Description:

Why this code fails in string "if let serializableElement = value as? Serializable"?

Seems to be correct, but fails with "warning: Swift runtime does not yet support dynamically querying conditional conformance" and goes into else block instead of if clouse

protocol Serializable {
    func serialize() -> String
}

extension Serializable {
    func serialize() -> String {
        return "\(self)"
    }
}

extension String: Serializable {}
extension Int: Serializable {}

extension Dictionary: Serializable where Key == String {
    func serialize() -> String {
        for (key, value) in self {
            result.append("\(key):")
            if let serializableElement = value as? Serializable {
                result.append((serializableElement.serialize()))
            } else {
                let mirror = Mirror(reflecting: value)
                print("self: \(self.customMirror.subjectType), element: \(mirror.subjectType)")
            }
        }
        return result
    }
}

let x = ["key11" : 5, "key2" : ["inner" : "hhhhh" ]].serialize()

print(x)
@belkadan
Copy link
Contributor

As the message says (along with the Xcode release notes), dynamic checking for conditional conformances was not implemented in Swift 4.1; we simply ran out of time in the release. It's in 4.2, though.

@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.
Projects
None yet
Development

No branches or pull requests

2 participants