I simplified my code that was getting the error into the following in order to show what the issue is. The problem seems to happen in subclasses of generics. Copy and past the code into a playground and you shoudl get the same results.
class MyClass {
convenience init?(succeed:Bool) {
guard succeed else {return nil}
self.init()
}
init(){}
}
class MySubClass:MyClass {}
class MyGenericClass<T> {
convenience init?(succeed:T) {
guard succeed as? Bool ?? false else {return nil}
self.init()
}
init(){}
}
class MyGenericSubClass<T>:MyGenericClass<T> {}
class MyTypedGenericSubClass:MyGenericClass<Bool> {}
MyClass(succeed: true) // Works
MySubClass(succeed: true) // Works
MyGenericClass<Bool>(succeed: true) // Works
MyGenericSubClass<Bool>(succeed: true) // Fails
MyTypedGenericSubClass(succeed: true) // Fails
/*
Gets the following error:
Playground execution failed: error: MyPlayground.playground:59:1: error: '(Bool) -> MyGenericSubClass<Bool>' is not convertible to '(Bool) -> MyGenericSubClass<Bool>?'
MyGenericSubClass<Bool>(succeed: true) // Fails
^~~~~~~~~~~~~~~~~~~~~~~
error:MyPlayground.playground:60:1: error: '(Bool) -> MyTypedGenericSubClass' is not convertible to '(Bool) -> MyTypedGenericSubClass?'
MyTypedGenericSubClass(succeed: true) // Fails
^~~~~~~~~~~~~~~~~~~~~~
*/
Is this the intended behavior?