You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
While attempting to write a protocol for both Data and DispatchData that covers their shared `enumerateBytes` method, I discovered that it is not really possible to do that. Consider the following example program:
If you try to suppress the label by changing the protocol method from func enumerateBytes(block: (UnsafeBufferPointer<UInt8>, Self.Index, inout Bool) -> Void) to func enumerateBytes(_ block: (UnsafeBufferPointer<UInt8>, Self.Index, inout Bool) -> Void), this will again fail to compile, this time because of DispatchData:
Given that these two data types can be bridged on Darwin, but not Linux, this inconsistency should probably be remedied.
(As a post-script, a tempting approach to bridge over this would be for my protocol to provide a default implementation for one case in terms of the other. However, because of the tail-closure syntax, doing this would cause an enormous number of compile errors.)
The text was updated successfully, but these errors were encountered:
Environment
Swift 4.2 beta
Additional Detail from JIRA
md5: 7f82935997669109761a47ee765077b8
Issue Description:
While attempting to write a protocol for both
Data
andDispatchData
that covers their shared `enumerateBytes` method, I discovered that it is not really possible to do that. Consider the following example program:This does not compile, because
Data
has no label on its block:If you try to suppress the label by changing the protocol method from
func enumerateBytes(block: (UnsafeBufferPointer<UInt8>, Self.Index, inout Bool) -> Void)
tofunc enumerateBytes(_ block: (UnsafeBufferPointer<UInt8>, Self.Index, inout Bool) -> Void)
, this will again fail to compile, this time because ofDispatchData
:Given that these two data types can be bridged on Darwin, but not Linux, this inconsistency should probably be remedied.
(As a post-script, a tempting approach to bridge over this would be for my protocol to provide a default implementation for one case in terms of the other. However, because of the tail-closure syntax, doing this would cause an enormous number of compile errors.)
The text was updated successfully, but these errors were encountered: