protocol P {} protocol Q {} struct S: P {} extension Q { func p() -> some P { return S() } } func foo(q: Q) -> any P { return q.p() // erase to any P }