Existentials are still missing in the language. Any advice how to rewrite the code so it still would do its job under the hood?
protocol Proto : class { // `A` is a generic type and therefore should stay as an associatedtype associatedtype A func performWith(_ a: A) } final class SomeType<B> { typealias ProtoB = Any<Proto> where Proto.A == B var protos: [ProtoB] init(_ protos: [ProtoB]) { self.protos = protos } func callProtosWith(_ b: B) { self.protos.forEach { $0.performWith(b) } } } I could make protocol Proto : BaseProto and safe an array of BaseProto but how do I convert it back to Proto when needed, so I could access performWith(_:) function? I cannot use the generic parameter list from SomeType to enforce this, because the class that conforms to Proto might not have the same base class, which is the intended behavior. -- Adrian Zubarev Sent with Airmail
_______________________________________________ swift-users mailing list swift-users@swift.org https://lists.swift.org/mailman/listinfo/swift-users