Skip to content

[Result Builders] Correct type witness substitution when computing inferred result builder attributes from protocol requirements. #39988

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 2 commits into from
Oct 30, 2021

Conversation

hborla
Copy link
Member

@hborla hborla commented Oct 30, 2021

Fix a few bugs when inferring a result builder attribute on a value witness from the protocol requirement:

  • Map protocol type parameters to their type witnesses to properly support Self and associated types inside result builder attributes.
  • Map type parameters from the conforming type into context. Result builders applied to function/property/subscript bodies are not part of the interface type; the builder type will only be used for calls to buildBlock and friends in the body.

Resolves: rdar://84818325

…ferred

result builder attributes from protocol requirements.
…itnesses,

always map type parameters into context.

For result builders applied to function/variable/subscript bodies, the builder
type will only be used for calls to `buildBlock` and friends inside the body,
for which we always want the contextual type of the builder, not the interface
type.
@hborla hborla requested a review from slavapestov October 30, 2021 02:45
Copy link
Contributor

@slavapestov slavapestov left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I was looking at the first commit and was about to nitpick the getSelfTypeInContext() then I saw the second commit. Never mind, LGTM!

@hborla
Copy link
Member Author

hborla commented Oct 30, 2021

@swift-ci please test source compatibility

@hborla
Copy link
Member Author

hborla commented Oct 30, 2021

@swift-ci please smoke test

@hborla hborla merged commit c31a590 into swiftlang:main Oct 30, 2021
@hborla hborla deleted the result-builder-attr-substitution branch October 30, 2021 09:09
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants