Sema: A call of a closure literal is noescape [4.0] #10041
Merged
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: Fixes a commonly-reported source compatibility regression in 4.0. If a closure's type was fully explicit (no type variables) we did not propagate the noescape bit from the call to the closure literal, thus we would require instance variables to be accessed with explicit "self." in cases where it was not needed before. Another related problem this also fixes was also present in 3.1 -- if a capture list was applied to a closure, we also required 'self.' qualification for instance variables (even if the capture list had nothing to do with 'self').
Scope of the issue: All the examples I saw involved immediately calling a closure literal, so I made a narrow fix for this case.
Origination: The original problem has existed for a long time but got worse recently.
Risk: Low, this only affects immediate calls of closures. The PR I submitted to master had a further cleanup of the logic, but it's not necessary here.
Tested: New tests added.
Reviewed by: @DougGregor
Radar: rdar://problem/32520406.