> Any advice how to rewrite the code so it still would do its job under the
> hood?
I'm not aware of any clean way to do this (with current Swift ;-) — but this
hack passes compilation:
protocol Proto : class {
// `A` is a generic type and therefore should stay as an associatedtype
associatedtype A
func performWith(_ a: A)
}
struct Box<B> {
var performWith: (B) -> Void
init<T: Proto>(value: T) where T.A == B {
self.performWith = value.performWith
}
}
final class SomeType<B> {
var protos: [Box<B>]
init(_ protos: [Box<B>]) {
self.protos = protos
}
func callProtosWith(_ b: B) {
self.protos.forEach {
$0.performWith(b)
}
}
}
_______________________________________________
swift-users mailing list
[email protected]
https://lists.swift.org/mailman/listinfo/swift-users