[6.1] Fix the demangling of sending result types when combined with isolation #78641
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.
When the symbol mangler mangles a function type, it adds operators representing different aspects of the type in a specific order. The demangler accumulates these operators on a stack, then needs to pop them off in the exact reverse of that order. Unfortunately, the demangler was trying to pop one operator (representing that the result type is
sending
) in the wrong order, causing it to fail to demangle names that combined that operator with certain other operators (representing function isolation, such as a global actor attribute).In assertion builds of the compiler, we verify that we can demangle every symbol we mangle, and declarations that featured a type such as
@MainActor () -> sending T
would trip the assertion. With assertions disabled, we would successfully mangle such symbols. As a result, we cannot reasonably change the mangling order to match the current demangler and must instead change the demangler to expect operators in the right order. This is somewhat unfortunate because the demangler is partially a runtime component (as is the mangler, although this code path is not heavily used).This patch fixes the demangler to expect the operators in the right order. This will cause assertions builds of the compiler to go back to successfully building code that combines these features, and it will allow newly-built runtimes to successfully demangle such types. We will need a follow-up compiler patch to fix the compiler to not attempt to exercise the runtime's ability to demangle such types on existing runtimes (which just means the 6.0 runtime).
Scope: affects all demangle paths on a combination of features that's somewhat uncommon
Risk: low
Testing: added new demangling tests
Issue: rdar://142443925
Reviewer: @gottesmm
Original PR: #78576.