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-9837] Optional<T>.none -> Optional<U>.none casting regression in generic context #52251

Closed
hamishknight opened this issue Feb 1, 2019 · 2 comments
Assignees
Labels
bug A deviation from expected or documented behavior. Also: expected but undesirable behavior. compiler The Swift compiler in itself regression runtime The Swift Runtime swift 5.0

Comments

@hamishknight
Copy link
Collaborator

Previous ID SR-9837
Radar rdar://problem/47743688
Original Reporter @hamishknight
Type Bug
Status Resolved
Resolution Done
Environment

Apple Swift version 5.0-dev (LLVM eb302e257f, Clang a113643bc4, Swift 646034c)
Target: x86_64-apple-darwin18.2.0

Additional Detail from JIRA
Votes 0
Component/s Compiler
Labels Bug, 5.0Regression, Runtime
Assignee @hamishknight
Priority Medium

md5: ec7bbde0897708940075adc9253e1aca

Issue Description:

In Swift 4.2 the following cast correctly succeeds:

func test<T>(_ type: T.Type) -> T? {
  return Any?.none as? T
}

print(test(Bool?.self)) // Optional(nil)

However, as discovered on the forums, in Swift 5 it incorrectly fails and prints nil instead. This does appear to be fixed on master, but we should add a test case.

@belkadan
Copy link
Contributor

belkadan commented Feb 1, 2019

cc @jckarter, @slavapestov

@jckarter
Copy link
Member

@mikeash took a look, and it looks like this is fixed in the most recent Swift 5 snapshots.

@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. compiler The Swift compiler in itself regression runtime The Swift Runtime swift 5.0
Projects
None yet
Development

No branches or pull requests

4 participants