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-14574] Generic parameter could not be inferred if I add a print statement or any other line #56926

Closed
4brunu opened this issue May 3, 2021 · 2 comments
Labels
bug A deviation from expected or documented behavior. Also: expected but undesirable behavior. compiler The Swift compiler in itself

Comments

@4brunu
Copy link

4brunu commented May 3, 2021

Previous ID SR-14574
Radar rdar://problem/77465708
Original Reporter @4brunu
Type Bug
Environment

macOS Big Sur 11.3 (20E232)
Xcode Version 12.5 (12E262)

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

md5: c803cb239fb04957e1b303199f40a2c1

Issue Description:

This code compiles normally, but if I uncomment one of the following print statements, or any other line, this will no longer compile, and throw the following error: Generic parameter 'T' could not be inferred

```
class Example {
static func test() {
Task.retry(task: { taskCompletion in
DispatchQueue.main.async {
//print("Uncomment me to throw error: Generic parameter 'T' could not be inferred")
taskCompletion(.success(()))
//print("Uncomment me to throw error: Generic parameter 'T' could not be inferred")
}
}, completion: { result in

switch result {
case .success:
print("success")
case .failure:
print("failure")
}
})
}
}

enum Task {
static func retry<T>(
task: @escaping (_ completion: @escaping (Result<T, Error>) -> Void) -> Void,
completion: @escaping (Result<T, Error>) -> Void
) {
task { result in
completion(result)
}
}
}
```

@typesanitizer
Copy link

@swift-ci create

@swift-ci swift-ci transferred this issue from apple/swift-issues Apr 25, 2022
@xedin
Copy link
Member

xedin commented Jul 20, 2022

This is fixed by SE-0326, example is the description type-checks successfully in 5.7.

@xedin xedin closed this as completed Jul 20, 2022
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
Projects
None yet
Development

No branches or pull requests

3 participants