[Ranted]Allow to compare generic types without providing a signature specialization

Improving the UI of generics among other things suggests to introduce existential containers for generic types, with syntax being any Optional, any Array, etc.

You would not be able to compare meta types as equal, but you could check values by casting:

var x: Array<Int> = [1, 2, 37]
var y: any Array = x
print(type(of: y)) // prints 'Array<Int>'
y = ["abc", "xyz"] // ok
print(type(of: y)) // prints 'Array<String>'

print(Array<Int>.self == (any Array).self) // prints 'false'
print(Array<String>.self == (any Array).self) // prints 'false'

var z: Any = y
print(z is Array<Bool>) // prints 'false'
print(z is Array<String>) // prints 'true'
print(z is any Array) // prints 'true'

@total_swiftification, does this solve your use case?

2 Likes