Avatar
Avatar
koher
伝播もできた。 @swift-5.7.3 @rethrows protocol P { func foo() throws } @rethrows protocol Q { associatedtype PType: P func makeP() -> PType } struct S1: P { func foo() { print("S1") } } struct S2: P { func foo() throws { print("S2") } } 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) }
S1 S2