[SR-10013] Compiler does not infer the correct method #52416
Labels
bug
A deviation from expected or documented behavior. Also: expected but undesirable behavior.
compiler
The Swift compiler in itself
diagnostics QoI
Bug: Diagnostics Quality of Implementation
type checker
Area → compiler: Semantic analysis
Attachment: Download
Environment
Xcode 10.1
Additional Detail from JIRA
md5: 4434578cd35fc77d0bb9598645f44df4
Issue Description:
Hi there!
I have a function with the following signature:
func handle(handler: ((_ foo: String) -> Void))
I have an extension function on the class with the following signature:
func handle<T>(handler: ((_ foo: String) throws -> T)) throws -> T
When I try to write code like the following, Swift infers the
handle
function that doesn't throw or return a value instead of the one that does, resulting in a compiler error:let testInt = try bugTest.handle { string in
{{ print(string)}}
{{ }}
{{ if (string == "baz") {}}
{{ throw TestError.baz}}
{{ }}
{{ return 42}}
{{}}}
I've attached a very detailed playground demonstrating exactly what I'm trying to do and why, with the reproducible test case included.
Thanks!
The text was updated successfully, but these errors were encountered: