Skip to content

Fold exportability checking into availability checking #34329

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 9 commits into from
Oct 20, 2020

Conversation

slavapestov
Copy link
Contributor

@slavapestov slavapestov commented Oct 16, 2020

In the previous PR, I introduced DeclAvailabilityChecker. The division of labor was as follows:

  • DeclAvailabilityChecker would diagnose references to unexported types from inlinable function signatures
  • ExportabilityChecker would diagnose references to unexported types from non-inlinable function signatures
  • The existing availability check would diagnose references to unexported declarations from inlinable function bodies

This PR folds ExportabilityChecker into DeclAvailabilityChecker, merging the first two code paths, and prepares the availability checking code to look at conformance availability as well as conformance exportability.

Builds upon #34325.

@slavapestov slavapestov force-pushed the nuke-exportability-checker branch from f7f4a70 to 3880658 Compare October 19, 2020 19:59
@slavapestov
Copy link
Contributor Author

@swift-ci Please smoke test

@slavapestov
Copy link
Contributor Author

@swift-ci Please test source compatibility

@slavapestov slavapestov marked this pull request as ready for review October 19, 2020 20:00
@slavapestov slavapestov requested a review from xymus October 19, 2020 20:00
@slavapestov slavapestov force-pushed the nuke-exportability-checker branch from 3880658 to 462bf2a Compare October 19, 2020 21:03
@slavapestov
Copy link
Contributor Author

@swift-ci Please smoke test

@slavapestov
Copy link
Contributor Author

@swift-ci Please test source compatibility

@slavapestov slavapestov force-pushed the nuke-exportability-checker branch from 462bf2a to de29cdd Compare October 19, 2020 23:08
@slavapestov
Copy link
Contributor Author

@swift-ci Please smoke test

Today, we check conformance exportability in two places:

1) For inlinable function bodies: in availability checking
2) For types in inlinable declaration signatures: in availability checking
3) For types in non-inlinable declaration signatures: in ExportabilityChecker

I want to merge 2) and 3) together, and also generalize the conformance
exportability check to check conformance availability as well.

This is a preliminary refactoring towards achieving this goal.
Availability checking already knows how to check exportability for
types and conformances referenced from inlinable function signatures
and bodies.

Let's generalize this to work on non-inlinable function signatures
as well, allowing us to get rid of the ExportabilityChecker altogether.
…ailability checking

The substitution map is checked elsewhere.
…type

The ExportContext describes the restrictions, if any, on what
declarations can be uttered in a specific place in the
program. Here, the place is either the signature of a
declaration, or the body of a function.
Converting the innermost DeclContext into a Decl won't work if
the innermost DeclContext is the parent context of a VarDecl.

Instead, use the relevant bit of state from the ExportContext,
which is computed correctly.

This fixes a regression caused by an earlier commit in this PR
which our test suite did not catch.
@slavapestov slavapestov force-pushed the nuke-exportability-checker branch from de29cdd to a824e5a Compare October 20, 2020 05:03
@slavapestov
Copy link
Contributor Author

@swift-ci Please smoke test

@slavapestov
Copy link
Contributor Author

@swift-ci Please test source compatibility

1 similar comment
@slavapestov
Copy link
Contributor Author

@swift-ci Please test source compatibility

@slavapestov slavapestov merged commit c0d664d into swiftlang:main Oct 20, 2020
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.

1 participant