Avatar
Avatar
omochimetaru
@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 }) }
swiftNightly BOT 12/28/2023 7:22 AM
exit status: 1 with <stdin>:38:9: warning: integer literal is unused 1 ^ <stdin>:39:9: warning: integer literal is unused 2 ^ <stdin>:40:9: warning: integer literal is unused 3 ^ <stdin>:41:5: error: missing return in closure expected to return '[any P]' }) ^