Avatar
@swift-main import Dispatch protocol P {} extension Int: P {} func useP(_ p: some P) {} struct S: P { init(@SBuilder builder: () -> [any P]) { self.ps = builder() } var ps: [any P] } @resultBuilder struct SBuilder { static func buildBlock(_ components: (any P)...) -> [any P] { components } } extension P where Self == S { static func s(@SBuilder builder: () -> [any P]) -> S { S(builder: builder) } } func main() { // これはできる useP(S { 1 2 3 }) // これはできない useP(.s { 1 2 3 }) }