Misleading Error Given For Type Inference Problem in Closure

Originator:nothingwasdelivered
Number:rdar://28152892 Date Originated:September 3, 2016
Status:Open Resolved:
Product:Xcode Product Version:8 beta 6
Classification: Reproducible:
 
Summary:
Swift 3's Data struct has a method defined as: func withUnsafeBytes<ResultType, ContentType>(_ body: (UnsafePointer<ContentType>) throws -> ResultType) rethrows -> ResultType

If you attempt to create a closure without clearly defining the type of ContentType, Xcode gives you an error stating that the problem is with the ResultType

Steps to Reproduce:
Attempt to use withUnsafeBytes(_:) without properly defining the type for generic type ContentType

Expected Results:
Xcode should give you an error that leads you to more clearly define the type of ContentType

Actual Results:
Error given:  Declared closure result 'Int' is incompatible with contextual type ‘ResultType’.


Version:
Xcode 8 Beta 6
OS X 10.11.6 (15G1004)

Notes:


Configuration:
MacbookPro 11,1

Comments


Please note: Reports posted here will not necessarily be seen by Apple. All problems should be submitted at bugreport.apple.com before they are posted here. Please only post information for Radars that you have filed yourself, and please do not include Apple confidential information in your posts. Thank you!