[6.4] introduce @_preInverseGenerics(except:)#89171
Open
kavon wants to merge 4 commits into
Open
Conversation
I'd like `InvertibleProtocolSet::allKnown()` to be evaluated at compile-time. (cherry picked from commit ceb302c)
@_preInverseGenerics(except: <inverses>) is an extension of the existing @_preInverseGenerics attribute that provides selective control over which inverse requirements are mangled into a declaration's symbol name. While the bare @_preInverseGenerics strips all inverse constraints (~Copyable and ~Escapable) from mangling, the 'except:' form allows specific inverses to be retained. This is needed when a type like Span already had ~Copyable mangled into its ABI-stable symbols and now needs to retroactively adopt ~Escapable without changing those existing symbols. You can now express that with `@_preInverseGenerics(except: ~Copyable)` to strip-out every inverse except ~Copyable to preserve the pre-existing ~Copyable-containing symbols. It requires the new experimental feature `PreInverseGenericsExcept`. rdar://176395527 (cherry picked from commit 19119ad)
Member
Author
|
@swift-ci test |
I added the warning based on an observation that it has no effect on members of the extension, but didn't validate whether it has some subtle effect on other symbols, such as those for conformances declared with that extension. To reduce confusion, it's better to not warn until it's safe enough to remove uses of it on extensions in the stdlib. Related to swiftlang#88976 (cherry picked from commit bcaa5b6)
Member
Author
|
@swift-ci test |
…ttribute We need an alias since `@_preInverseGenerics(except: ...)` has custom parsing that older compilers aren't designed to handle. Only simple decl attributes are parsed correctly by older compilers, so this alias allows you to write this: ``` @_preInverseGenericsExceptCopyable var x = 0 var x = 0 ``` Which all helps with the introduction of Span<~Escapable>. related to rdar://176395527 (cherry picked from commit 14c2574)
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Explanation: Introduces additional flexibility for avoiding mangling changes by expanding the @_preInverseGenerics attribute with support for filtering-out inverses except some subset. Needed to support Span<~Escapable> without ABI break.
Scope: Upgrades a bool AllowInverses in the mangler into a InvertibleProtocolSet of allowed inverses. Includes parsing and serialization to populate that set.
Issues: rdar://176395527
Risk: Low. The only risk is that this messes up mangling for ordinary @_preInverseGenerics (or just symbols containing inverses in general), since this generalizes its implementation. But the changes that are risky are pretty limited in scope so they're easier to inspect.
Testing: regression tests included
Cherry-pick of: #88976 & #89264 & #89269