Why doesn’t `Type` work with backticks?

why doesn’t this work?

enum E 
{
    enum `Type`
    {
        static 
        var a:Int 
        {
            0
        }
    }
}

print(E.`Type`.a)
error: type 'E.Type' has no member 'a'
print(E.`Type`.a)
      ~~~~~~~~ ^

i’m doing exactly what the fixit says:

error: type member must not be named 'Type', since it would conflict with the 'foo.Type' expression
    enum Type
         ^
note: if this name is unavoidable, use backticks to escape it
    enum Type
         ^~~~
         `Type`

is Type just always disallowed, even with backticks?

Yes. The metatype should probably be a special member like init and subscript, but no one's done that work yet. (I think there's already a bug for it, even.)

1 Like