Avatar
↓これは無理。 throws を互い違いに付けた場合。 @swift-5.7.3 @rethrows protocol P { func foo() throws func bar() throws } @rethrows protocol Q { associatedtype PType: P func makeP() -> PType } struct S1: P { func foo() { print("S1.foo") } func bar() throws { print("S1.bar") } } struct S2: P { func foo() throws { print("S2.foo") } func bar() { print("S2.bar") } } struct T1: Q { func makeP() -> S1 { S1() } } struct T2: Q { func makeP() -> S2 { S2() } } func callFoo<T: Q>(from q: T) rethrows { try q.makeP().foo() } callFoo(from: T1()) do { try callFoo(from: T2()) } catch { print(error) }