Open
Description
Previous ID | SR-1326 |
Radar | None |
Original Reporter | babt (JIRA User) |
Type | Bug |
Environment
OS X 10.11.4, Ubuntu 15.10
Additional Detail from JIRA
Votes | 2 |
Component/s | Foundation |
Labels | Bug, Linux |
Assignee | None |
Priority | Medium |
md5: 038bf2888e67b281907ad63c90829211
Issue Description:
This code snippet works on OS X but not on Linux.
babt@Swift-TestVM:/usr/include/openssl$ swift
Welcome to Swift version 3.0-dev (LLVM 752e1430fc, Clang 1e6cba3ce3, Swift 56052cfe61). Type :help for assistance.
1> import Foundation
2>
3> public protocol CDigest {
4. func digest(name: String) -> Self
5. }
6>
7> extension NSData: CDigest {
8.
9. public func digest(name: String) -> Self {
10.
11. var myName = name
12. let data = self.dynamicType.init(bytes: &myName, length: myName.utf8.count)
13. return data
14. }
15. }
error: repl.swift:12:37: error: constructing an object of class type 'Self' with a metatype value must use a 'required' initializer
let data = self.dynamicType.init(bytes: &myName, length: myName.utf8.count)
~~~~~~~~~~~~~~~~ ^
Foundation.NSData:2:24: note: selected non-required initializer 'init(bytes:length:)'
public convenience init(bytes: UnsafePointer<Swift.Void>?, length: Int)
^
The error I'm receiving appears to be correct but this same code works fine on OS X which indicates to me that that initializer on OS X is marked as `required`. Therefore, should the initializer on Linux also be marked as required. Looking at the source, it not currently. Which one is right? If OS X is right (which I hope to be the case), I can prepare a PR with the fix.