I have the following (I've simplified it to the most basic case):
class Something<H: Hashable> {
}
func function<H: NSDate>() -> Something<H> {
let s: Something<NSDate> = Something()
return s
}
The error is on the return s
line:
NSDate is not identical to 'H'
But this doesn't make an sense as any subclass of NSDate
or NSDate
itself should be allowed by this.
For example the following works:
let dateSomething: Something<NSDate> = Something()
functionWorks(dateSomething)
func functionWorks<H: NSDate>(parameter: Something<H>) {
}
Does anyone have any ideas why the first example isn't working? I'm currently thinking it might be an issue with Swift itself...