is it possible to determine if a composed Any.Type contains a specific Any.Type?
(A & B).self contains A.self => true
(B & C).self contains A.self => false
Code Example
protocol A {}
protocol B {}
typealias AB = A & B
func conformsToA(_ type: Any.Type) -> Bool {
return type == A.self
}
print(conformsToA(A.self)) // true
print(conformsToA(AB.self)) // false (but should be true)
i could add a specific clause for type == (A & B).self inside of conformsToA(_:), but this quickly becomes unmanageable. imagine if protocols C-Z are introduced and i tried to check something like:
conformsToA((A & C & E & Z).self)
Another Attempt Using Alistra's 2nd Approach
protocol A {}
protocol B {}
typealias AB = A & B
func conformsToA<T>(_ t1: T.Type) -> Bool {
return T.self is A
}
print(conformsToA(A.self)) // false (but should be true)
print(conformsToA(AB.self)) // false (but should be true)