I do not have a concrete use case at my hands, as I just tried if this wasn‘t already a feature and found out that it‘s not. I can try to look up our code base later and search for .Kind types which I probably used because the .Type namespace was taken by the language.
extension Firmware {
public struct Version: Hashable, Comparable {
public enum Kind: Hashable {
case release
case beta(UInt)
}
}
}
public struct Permission: Equatable {
public enum Kind {
case notSupported
case readOnly
case readWrite
}
}
extension Transition.Context {
public enum Kind {
case push
case pop
}
}
// etc.
Nothing truly groundbreaking.
Well it might be that this pitch is doomed as I kinda proposed to introduce the ability to shadow over metatype namespaces.
Counter example would be the fact that back ticks cannot overload:
enum Foo {
case a
case `a` // error - Invalid redeclaration of 'a'
}
struct `Foo` {} // error - Invalid redeclaration of 'Foo'
It seems what's suggested already works in Swift 5. For example, I managed to get the following to compile using Xcode 13.1:
class GameObjectNode {
enum `Type`: String, Codable {
case ship
case player
case asteroid
case spaceStation
}
class var metatype: GameObjectNode.`Type`? {
return nil
}
}
In such context you're shadowing the .Type namespace, I think this is why it works there. Try using the type from a standalone function, it will likely fail the expectation.