-
Notifications
You must be signed in to change notification settings - Fork 10.5k
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
Allow implicit self in escaping closures when self usage is unlikely to cause cycle #23934
Conversation
6778567
to
3446add
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is awesome, just a few suggestions.
Hi @gregomni, thanks for the comments! I’ll have a chance to make changes re: your feedback this weekend. |
c0efff6
to
df5f6a1
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This looks pretty good! I have some minor suggestions, but they're mostly stylistic, plus a couple of edge cases.
If you fix the merge conflict and @ me, I'll kick off tests. |
@brentdax Implementation updated and conflicts resolved. Made some new changes in |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Very minor suggestions, but I'm happy with this overall!
@brentdax Thanks for the comments! Sorry it took me a bit to get back to you; I had to update the implementation to integrate with the new AST scope lookup system. I have a working implementation now, so once I polish that up I’ll push it up and add the tests you’ve called out! |
To be honest I just created it because that's what Ted/Doug were trying to do. You can use it in Xcode to check if everything works and behaves as expected I guess. That's weird - I don't get such an error (I am using Xcode 11.3 on macOS 10.15.1). The toolchain needs to be placed in |
Ah, gotcha. @tkremenek @DougGregor this is passing CI now and is ready to merge on my end! |
It looks like you haven't run full tests recently, so just to be conservative, I'll do a test-and-merge. @swift-ci please test and merge |
@brentdax Should the test-and-merge job be reflected in the check statuses below? I'm not seeing anything change (still just the smoke test and build toolchain jobs). |
It will update soon, it's running: https://ci.swift.org/view/Pull%20Request/job/swift-PR-merge/2194/ |
Infrastructure problems... let’s try again: @swift-ci please test |
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
@swift-ci please test Linux |
@swift-ci please test macOS |
@brentdax Looks like the tests @theblixguy kicked off succeeded finally, but this still needs one last nudge to actually merge it :) |
Let's run source compatibility tests as well, just to be extra sure. If that passes too, we can merge this: @swift-ci please test source compatibility |
Thank you @theblixguy! For future reference, are these all steps that I could have run myself (i.e., was I bothering you two needlessly)? |
You need commit access to run tests on CI, but I am happy to run them for you if needed! For testing locally, there's a doc: https://github.com/apple/swift/blob/master/docs/Testing.md (instructions for running source compat suite locally is here: https://github.com/apple/swift-source-compat-suite). |
@swift-ci please test source compatibility debug |
@swift-ci please test source compatibility release |
Oh it would be great if this could end up in 5.2. I have a DSL that would be much much nicer to use with this. |
@Jumhyn Do you mind adding this to the changelog and also update the proposal as "Implemented" on Swift evolution repo? |
@theblixguy Sure thing. Do you know what heading it should be put under in the changelog since it missed 5.2? |
It should be under “Swift Next”. Also, I’m sorry for suggesting to update the proposal, since we don’t know which version of Swift this will end up in, its best to keep the current status as-is. |
Great, done. Once this makes it into a Swift release I'll update the swift-evolution PR with the version number so that it can be merged in. |
Update the lookup logic for closures to allow resolution of implicit
self
to resolve to any direct captures ofself
(e.g.{ [self] in ... }
) in closures. Also introduce new diagnostic logic to suggest such a capture as a fix-it for implicitself
in an escaping closure.This is the implementation for an incoming Swift Evolution proposal.
Resolves SR-10218.