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-7964] Overloading a method with an optional parameter chooses wrong overload #50499

Closed
ffried opened this issue Jun 11, 2018 · 0 comments
Closed
Labels
bug A deviation from expected or documented behavior. Also: expected but undesirable behavior. compiler The Swift compiler in itself regression swift 4.2 type checker Area → compiler: Semantic analysis

Comments

@ffried
Copy link
Contributor

ffried commented Jun 11, 2018

Previous ID SR-7964
Radar None
Original Reporter @ffried
Type Bug
Status Resolved
Resolution Duplicate
Environment

Apple Swift version 4.2 (swiftlang-1000.0.16.7 clang-1000.10.25.3)
Target: x86_64-apple-darwin17.6.0

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

md5: aee7f963f20817fccf8bc7e6367f9ff8

duplicates:

  • SR-7884 Overload resolution picks optional variant even when value is not optional

Issue Description:

Given the following code:

func doThis<T>(with value: T) {
   print("Do this nonoptionally!")
}

func doThis<T>(with value: T?) {
   print("Do this optionally!")
}

let value: String = "ABC"
doThis(with: value)

The output is "Do this optionally" in Swift 4.1. I'd assume that the Swift 4.1 behaviour was correct here, since the value is clearly not an optional.

@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 swift 4.2 type checker Area → compiler: Semantic analysis
Projects
None yet
Development

No branches or pull requests

2 participants