Avatar
Avatar
Iceman
@swift-5.6.3 @swift-5.7.3 protocol P {} struct S: P {} extension Error { func f() -> some P { S() } } extension String: Error {} var foo: some P { "".f() } var bar: some P { ("" as any Error).f() } (edited)
exit status: 1 with stderr:<stdin>:17:21: error: type 'any P' cannot conform to 'P' ("" as any Error).f() ^ <stdin>:17:21: note: only concrete types such as structs, enums and classes can conform to protocols ("" as any Error).f() ^ <stdin>:16:10: note: required by opaque return type of var 'bar' var bar: some P { ^~~~~~ (edited)