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

Comments

@hamishknight
Copy link
Collaborator

@hamishknight hamishknight commented Feb 1, 2019

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 belkadan commented Feb 1, 2019

@jckarter
Copy link
Member

@jckarter jckarter commented Feb 12, 2019

@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
Projects
None yet
Development

No branches or pull requests

3 participants