Skip to content

Conversation

DougGregor
Copy link
Member

@DougGregor DougGregor commented Jul 20, 2020

The use of "if #available" in function builders can subvert availability
checking if the function builder carries all type information for the
values within the "then" block outside of the "else" block. Tighten up
the model in two ways:

  • Check whether the type coming out of an "if #available" references
    any declarations that are not available in the outer context, to close
    up the model.
  • If the function builder provides a buildLimitedAvailability(_:)
    operation, call that on the result of the "then" block in an "if
    that it cannot leak out of the "if #available"; if it doesn't, the
    check above will still fire.

Stage this in with a warning so function builders out there in the wild
can adapt. We'll upgrade the warning to an error later.

Fixes rdar://problem/65021017.
Original: #32994

The use of "if #available" in function builders can subvert availability
checking if the function builder carries all type information for the
values within the "then" block outside of the "else" block. Tighten up
the model in two ways:

* Check whether the type coming out of an "if #available" references
any declarations that are not available in the outer context, to close
up the model.
* If the function builder provides a buildLimitedAvailability(_:)
operation, call that on the result of the "then" block in an "if
that it cannot leak out of the "if #available"; if it doesn't, the
check above will still fire.

Stage this in with a warning so function builders out there in the wild
can adapt. We'll upgrade the warning to an error later.

Fixes rdar://problem/65021017.
@DougGregor DougGregor requested a review from a team as a code owner July 20, 2020 04:26
@DougGregor
Copy link
Member Author

@swift-ci please test

@swift-ci
Copy link
Contributor

Build failed
Swift Test OS X Platform
Git Sha - f506a67

@DougGregor
Copy link
Member Author

@swift-ci please test macOS

@DougGregor DougGregor merged commit 62efa55 into swiftlang:release/5.3 Jul 21, 2020
@DougGregor DougGregor deleted the function-builder-limited-availability-5.3 branch July 21, 2020 18:14
@AnthonyLatsis AnthonyLatsis added swift 5.3 🍒 release cherry pick Flag: Release branch cherry picks labels Jan 8, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

🍒 release cherry pick Flag: Release branch cherry picks swift 5.3

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants