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-7875] Type inference regression for overloaded generic function with function parameters in Swift 4.2 #50410

Closed
swift-ci opened this issue Jun 5, 2018 · 4 comments
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

@swift-ci
Copy link
Collaborator

swift-ci commented Jun 5, 2018

Previous ID SR-7875
Radar rdar://problem/40810000
Original Reporter stephan (JIRA User)
Type Bug
Status Resolved
Resolution Done
Additional Detail from JIRA
Votes 0
Component/s Compiler
Labels Bug, 4.2Regression, TypeChecker
Assignee stephan (JIRA)
Priority Medium

md5: e83cb9d99c9dd63ab9a8d35771deaf00

Issue Description:

The following code compiles with Xcode 9.4 (Apple Swift version 4.1.2 (swiftlang-902.0.54 clang-902.0.39.2)) but fails to compile with Xcode 10 Beta (Apple Swift version 4.2 (swiftlang-1000.0.16.7 clang-1000.10.25.3)).

protocol Proto {}
class Base {}
class Test : Base, Proto {}

struct A {}
struct B {}

func overloaded<T: Proto & Base>(_ f: () -> T, _ g: (T, A) -> ()) {}
func overloaded<T: Proto & Base>(_ f: () -> T, _ g: (T, B) -> ()) {}

func f() -> Test { return Test() }

func g<T: Proto & Base>(_ t: T, _ a: A) -> () {}

func test() {
  overloaded(f, g as (Test, A) -> ())
  overloaded(f, g) // error
}
test.swift:17:17: error: generic parameter 'T' could not be inferred
  overloaded(f, g)
                ^
test.swift:13:6: note: in call to function 'g'
func g<T: Proto & Base>(_ t: T, _ a: A) -> () {}
     ^
@belkadan
Copy link
Contributor

belkadan commented Jun 5, 2018

@swift-ci create

@rudkx
Copy link
Member

rudkx commented Jun 19, 2018

I opened a PR with a fix: #17317

@swift-ci
Copy link
Collaborator Author

Comment by Stephan Tolksdorf (JIRA)

Thanks! 🙂

@rudkx
Copy link
Member

rudkx commented Jun 19, 2018

Merged to master: 9f30ed6
Merged to swift-4.2-branch: 42890b8

Can you confirm with a future swift-4.2-branch snapshot and close when confirmed?

@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

4 participants