KeyPath with a generic protocol constraint

I have a protocol, P, with one requirement for returning a KeyPath that conforms to another protocol Q like so:

protocol P {
	static var path: KeyPath<Self, Q> { get }

protocol Q {}

struct A: Q {}

struct Foo: P {
	let x: A
	static var path: KeyPath<Foo, Q> {
		return \.x

This doesn’t compile though, since I get the error “Key path value type ‘A’ cannot be converted to contextual type ‘Q’”. I can work around this by force casting:

static var path: KeyPath<Foo, Q> {
    let p = \.x as! KeyPath<Foo, Q>
    return p

But I end up losing the type safety KeyPaths provide in the first place.
Is it possible to do something like this at the moment with KeyPaths, without resorting to PartialKeyPath?

KeyPath aren’t covariant, but you can have a look here for workarounds.

Yeah I had some issues a few days ago where I started using Key Paths in our project, which made the API surface by far more convenient. IIRC there was some discussion around covariance and generics in Swift and if I’m not totally wrong, someone has pitched an idea of explicit notation for for covariance (type keyword like). That would be really cool, and I’d support the idea of making Key Paths covariant to be honest. However I don’t remember which thread that was.