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-13742] Allow "case let value as [Int]" and remove the diagnostic that it is not implemented #56139

Open
ktoso opened this issue Oct 15, 2020 · 3 comments

Comments

@ktoso
Copy link
Member

@ktoso ktoso commented Oct 15, 2020

Previous ID SR-13742
Radar rdar://problem/70336498
Original Reporter @ktoso
Type Bug
Additional Detail from JIRA
Votes 0
Component/s Compiler
Labels Bug, StarterBug
Assignee @ktoso
Priority Medium

md5: d4a4c363d3b5f5288974990ee8ab9dfc

Issue Description:

The following code:

extension Array {
    func lol() -> String {
        switch self {
            case let value as [Int]: return "int"
            default: return "no"
        }
    }
}

yields:

// Swift version 5.3-dev (LLVM 2ea629d94ab01c3, Swift d3108db2429b29b)
// Target: x86_64-apple-darwin20.1.0
$SWIFT_EXEC Hello.swift
Hello.swift:5:28: error: collection downcast in cast pattern is not implemented; use an explicit downcast to '[Int]' instead
            case let value as [Int]: return "int"
                           ^

@jckarter suggests that implementation wise this isn't true anymore, just that the diagnostic is outdated.

@ktoso
Copy link
Member Author

@ktoso ktoso commented Oct 15, 2020

@swift-ci create

@jckarter
Copy link
Member

@jckarter jckarter commented Oct 15, 2020

Hopefully this is only a matter of removing that diagnostic, and validating that the pattern works as expected, since these days the runtime dynamic cast implementation ought to be able to handle collection casts.

@ktoso
Copy link
Member Author

@ktoso ktoso commented Oct 16, 2020

That seems to be the case indeed! Thanks a lot, PR: #34328

@swift-ci swift-ci transferred this issue from apple/swift-issues Apr 25, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants