[6.0][Distributed] Avoid infinite recursion in distributed thunk on protocol extension #73033
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.
Description: Because of the new ways we handle distributed requirements to support distributed resolvable protocols, we now have protocol requirements for both the thunk and the real method. A distributed thunk inside a protocol extension now ended up calling "itself" through protocol witness, but instead should always call the "real" method.
Without this patch such situation would end up in an infinite recurstion executing such method from executeDistributedTarget when the method was a default impl provided by extension on a protocol.
This patch resolves this by becoming contextually aware of the distributed thunk, and allowing it to always call the "real" method.
Scope of the issue: The issue specifically affects Swift 6.x (since introduction of @_DistributedProtocol), and specifically
distributed func
declared in anextension
of aprotocol
.Risk: Low, no impact on other code than the described situation.
Testing: CI testing, manually verified the reproducer as well.
Reviewed by: @xedin
Original PR: #73032
Radar: rdar://125445347