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: https://bugs.swift.org/browse/SR-10953

Terms of Service

Privacy Policy

Cookie Policy