Skip to content

[CSApply] NFC: Clean up some duplicated logic for propagating async from contextual types to closure types. #37282

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 1 commit into from
May 12, 2021

Conversation

hborla
Copy link
Member

@hborla hborla commented May 6, 2021

This is a follow-up to #37263, where I accidentally duplicated some code in coerceToType. The new code is clearer about when async is propagated to closure types, which is when the effect is not polymorphic or when the closure inherits the surrounding actor context.

Note that this change preserves the behavior that async is propagated to closures that inherit the surrounding actor context, even if the closure is an argument to a reasync function. I'm not actually sure how @_inheritActorContext and reasync are supposed to interact.

`async` from contextual types to closure types.

This preserves the behavior that `async` is propagated to closures that
should inherit the surrounding actor context, even if the closure is an
argument to a reasync function.
@hborla hborla requested review from xedin and DougGregor May 6, 2021 01:59
@hborla
Copy link
Member Author

hborla commented May 6, 2021

@swift-ci please smoke test

@hborla hborla requested a review from slavapestov May 6, 2021 17:29
if (auto *call = getAsExpr<ApplyExpr>(locator.getAnchor())) {
if (auto *declRef = dyn_cast<DeclRefExpr>(call->getFn())) {
if (auto *fn = dyn_cast<AbstractFunctionDecl>(declRef->getDecl()))
return !fn->hasPolymorphicEffect(kind);
return fn->hasPolymorphicEffect(kind);
Copy link
Contributor

Choose a reason for hiding this comment

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

IHMO naming of this method could be improved it's clear what polymorphism has to do with this and there is no comment at the declaration site. @hborla told me that this is about interaction between reasync/rethrows and async/throws attributes.

@hborla
Copy link
Member Author

hborla commented May 12, 2021

@swift-ci please smoke test

@hborla hborla merged commit eeeea25 into swiftlang:main May 12, 2021
@hborla hborla deleted the propagate-async-to-closure branch May 12, 2021 15:56
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