Swift crash converting [() -> T] to [() -> Protocol]
| Originator: | robnapier | ||
| Number: | rdar://21592532 | Date Originated: | 29-Jun-2015 12:40 PM |
| Status: | Open | Resolved: | |
| Product: | Developer Tools | Product Version: | Swift 2b2 |
| Classification: | Crash/Hang/Data Loss | Reproducible: | Always |
The following code crashes the compiler. Injecting “as DecryptorType?” resolves the crash and successfully compiles.
protocol DataSinkType: class {}
// Removing DataSinkType conformance converts crash to error:
// Function signature '([UInt8]) -> PasswordDecryptorV3?' is not compatible with expected type '([UInt8]) -> DecryptorType?'
// Along with incorrect Fix-it (suggesting I wrap it in a closure)
protocol DecryptorType: DataSinkType {}
final class PasswordDecryptorV3: DecryptorType {
init?() {}
}
final class Decryptor {
let decryptors: [() -> DecryptorType?]
init(password: String) {
self.decryptors = [
( { PasswordDecryptorV3()
// as DecryptorType? // Uncommenting this line removes crash and successfully compiles
})
]
}
}
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!