Does a protocol metatype have these instance members or not?

protocol P {
  static func foo()
}

extension P {
  static func bar() {}
}

P.self.bar() // error: Static member 'bar' cannot be used on protocol metatype 'P.Protocol'
P.self.foo() // error: Static member 'foo' cannot be used on protocol metatype 'P.Protocol'

The message says the these methods are not allowed to be used directly, but it does not say that the protocol metatype itself does not have these methods. So where is the truth?

cc @Joe_Groff

They can't be used because they are not available on the protocol's own metatype. They need a concrete type to be applied to.

I know that fact, but why are these still presented by autocompletion in Xcode? Is this a bug or intended?

That's a bug.

2 Likes

Filed: [SR-10953] Invalid exposure of static type members as instance members on a protocol metatype · Issue #53344 · apple/swift · GitHub

1 Like