we're doing some extensive usage of type(of:) to verify the contents of some collections of values that adhere to a bunch of protocols in our tests. I'm re-reading the documentation of type(of:)Apple Developer Documentation and since the return type Metatype in the docs isn't clickable am wondering where can I learn more about that type.
It seems that you can compare two results of type(of:) with ==(::) here Apple Developer Documentation so Metatype must be a Type too but I'd love to see if there are any docs about it.
The Metatype that type(of:) returns is the "type of a type", e.g., a type which represents information about the type of something else. For instance, the type of 42 may be Int, and the type which represents the Int type itself (i.e., the metatype of Int) can be referred to as Int.self. Metatypes are regular values in and of themselves, though are largely handled pretty specially by the compiler, so you won't find much about them by, e.g., Cmd-clicking in Xcode because their implementation is largely in the Swift compiler itself rather than in Swift source code. (Metatypes also have metatypes themselves, e.g. Int.Type.self represents the metatype of the metatype of Int, and Int.Type.Type.self represents... and so on ad infinitum.)
As far as the source of type(of:) itself, Metatype is regular generic argument that is bound by the type checker in the compiler to be the actual type of the argument that you pass in; i.e., the compiler figures out the actual runtime type of the value you pass in, and gives it back to you (e.g. type(of: 5) → Int.self). (The nameMetatype isn't actually special here — it would work identically if it were called Foo or R or anything else.)
The Swift Reference Manual page on types has slightly more information about metatypes that might be helpful, though it is a bit brief. The compiler docs has a Lexicon.md reference which also briefly mentions metatypes, and the rest of the compiler docs have a few more hits if you want to see a bit more related information. Otherwise, the best reference will the the actual compiler source, but that's more dense to get through.
More Info on type(of:) specifically
The thing that is special about Metatype is how the compiler figures out what the value of the argument should be, because typically, the concrete values of generic arguments are figured out based on how those arguments are used in the function, and how the function is called. (And if you notice, Metatype isn't actually used anywhere as input to the function itself!) But the resulting value could be any old type, and there's nothing special about it.
As an interesting point of comparison, you can see that the class_getClassMethod() function of the Objective C runtime is really just a wrapper that calls class_getInstanceMethod on the metaclass: