which is a bit confusing, as it was merged into main way back in 2022 and I'd expect the upcoming feature flag to work from 5.8+ (we're on the latest 5.10)
This feature sorts out a blocking issue for us (tried it with the Swift 6 snapshot which works great, but doesn't work for other stuff....), so we'd love to be able to turn it on.
As you note, the feature (implicitly opened existentials) was implemented before upcoming feature flags in general as a feature were implemented. Taking a look through the commit history, the issue here you're encountering appears to be that, while implementation work for implicitly opened existentials was merged in 2022, the specific feature flagImplicitOpenExistentials and the accompanying behavior change gated behind that flag were not fully implemented until recently.
So unless I'm mistaken, you'll be able to turn on this feature flag in the (default) Swift 5 language mode when using Swift 6.0, but not earlier.
Ouch. Thanks a lot @xwu for helping decipher the tea leaves - there weee just so many references to this feature as an example going way back, but that explains then… guess we’re stuck for some time then until 6.0
That we did and it worked fine for our small reproducer, unfortunately we can’t build our full stack with 6.0 toolchain yet.
Hm… are you sure the upcoming feature flag is even needed? I just dropped the example code from the proposal into an empty swift file, and it compiles and runs without error with Swift 5.10. My test case:
protocol P {
associatedtype A
func getA() -> A
}
struct S: P {
func getA() -> Int {
42
}
}
func takeP<T: P>(_ value: T) {
print(value.getA())
}
func test(p: any P) {
takeP(p) // no error here anymore!
}
let s = S()
test(p: s)