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-12163] Getter function of a computed variable with "some" type cannot return a value of "some" type #54588

Closed
swift-ci opened this issue Feb 8, 2020 · 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 type checker Area → compiler: Semantic analysis

Comments

@swift-ci
Copy link
Collaborator

swift-ci commented Feb 8, 2020

Previous ID SR-12163
Radar None
Original Reporter xy (JIRA User)
Type Bug
Status Resolved
Resolution Invalid

Attachment: Download

Environment

iPadOS 13.3 playground

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

md5: 345d1505e5400a83da6ee12f249684c0

Issue Description:

❌ Bug: a getter function of a computed variable with "some" type cannot return a value of the same "some" type. 👎

✔ Fix: make getter functions of computed vars with "some" type able to return a value of the same "some" type. 👍

@theblixguy
Copy link
Collaborator

This is not a bug. From the proposal itself:

The implementation of a function returning an opaque type 
must return a value of the same concrete type T from each 
return statement, and T must meet all of the constraints 
stated on the opaque type

If you’re using SwiftUI, you should wrap the return value in AnyView to erase the type.

@swift-ci swift-ci transferred this issue from apple/swift-issues Apr 25, 2022
@AnthonyLatsis AnthonyLatsis added the compiler The Swift compiler in itself label Dec 13, 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 opaque types Feature → types: opaque types type checker Area → compiler: Semantic analysis
Projects
None yet
Development

No branches or pull requests

3 participants