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-10723] Opaque Result Type does not work on local variable #53120

Open
omochi opened this issue May 21, 2019 · 1 comment
Open

[SR-10723] Opaque Result Type does not work on local variable #53120

omochi opened this issue May 21, 2019 · 1 comment
Labels
bug A deviation from expected or documented behavior. Also: expected but undesirable behavior. compiler The Swift compiler in itself opaque types Feature → types: opaque types

Comments

@omochi
Copy link
Collaborator

omochi commented May 21, 2019

Previous ID SR-10723
Radar None
Original Reporter @omochi
Type Bug
Environment

swift-DEVELOPMENT-SNAPSHOT-2019-05-15-a.

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

md5: a0bd45a112a4032da0f956a2c79354a0

Issue Description:

These code can not compile.

[omochi@omochi-iMac-PC43 check]$ cat c1.swift
let strings: some Collection = ["hello", "world"]
[omochi@omochi-iMac-PC43 check]$ swift c1.swift
c1.swift:1:32: error: cannot convert value of type '[String]' to specified type 'some Collection'
let strings: some Collection = ["hello", "world"]
                               ^~~~~~~~~~~~~~~~~~
                                                  as! some Collection
[omochi@omochi-iMac-PC43 check]$ cat c2.swift
public protocol P {
    mutating func flip()
}

private struct Witness: P {
    mutating func flip() { /* ... */ }
}

public var someP: some P = Witness()
[omochi@omochi-iMac-PC43 check]$ swift c2.swift
c2.swift:9:28: error: cannot convert value of type 'Witness' to specified type 'some P'
public var someP: some P = Witness()
                           ^~~~~~~~~
                                     as! some P

But both are in proposal document.
https://github.com/apple/swift-evolution/blob/master/proposals/0244-opaque-result-types.md

@belkadan
Copy link
Contributor

cc @jckarter

@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
Labels
bug A deviation from expected or documented behavior. Also: expected but undesirable behavior. compiler The Swift compiler in itself opaque types Feature → types: opaque types
Projects
None yet
Development

No branches or pull requests

2 participants