+1. This solves an important problem in a way that fits well with how Swift already handles similar things, and appears to cover everything we need as a library developer who tries to adopt new Swift features promptly while still maintaining compatibility with old versions.
One thought I had while looking at the current set of Swift 6 things which will use this is that we might not actually use hasFeature()
. Valid code with StrictConcurrency
and ExistentialAny
enabled should be a strict subset of valid code without them, and other than maybe ImplicitOpenExistentials
the rest are things that don't make sense to enable until we can rely on them always being available. This is probably a good thing; I was worried about a proliferation of #if
s but at least for these features we'll probably avoid them. hasFeature()
absolutely should exist, though, and I'm happy to see the changes to #if
parsing to make similar future additions work better.
Duplicating our Package.swift to use this is going to be painful (it's a few hundred lines of code...) but that's a totally separate problem to solve. I really wish SPM let us declare a supported range of versions rather than a single one and use #if
rather than duplicating the file.