Hello, is this a missing implementation, isn't it? I feel that it should be possible to use optional generic argument, but it is not. Is there a workaround for this?
here is an example of source code which doesn't compile.
protocol Dependency {}
protocol Interface {
associatedtype D: Dependency
func use(_ input: D)
}
struct SomeDependency: Dependency {}
class SomeImplementation: Interface {
typealias D = SomeDependency
func use(_ input: D) {
}
}
func handle<I: Interface>(_ interface: I?) where I.D == SomeDependency {
let dependency = SomeDependency()
interface?.use(dependency)
}
let input = SomeImplementation()
handle(input)
handle<SomeImplementation>(nil) // Cannot explicitly specialize a generic function
handle(nil) // Generic parameter 'I' could not be inferred