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

Closed
ktoso opened this issue Oct 15, 2020 · 3 comments · Fixed by #60682
Closed
Assignees
Labels
bug A deviation from expected or documented behavior. Also: expected but undesirable behavior. compiler The Swift compiler in itself good first issue Good for newcomers

Comments

@ktoso
Copy link
Member

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 commented Oct 15, 2020

@swift-ci create

@jckarter
Copy link
Member

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 commented Oct 16, 2020

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

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 good first issue Good for newcomers
Projects
None yet
3 participants