Skip to content

Conversation

@xymus
Copy link
Contributor

@xymus xymus commented Sep 26, 2023

Extend exportability checking to support non-public imports in some cases. Error on conformances imported from a non-public import is used in API, and on typealiases that desugars to a type behind a non-public import is used in API. Do no use the exportability checking logic for other checks that are already handled by the checks on the access levels.

…e code

Conformances imported as non-public cannot be used in API or inlinable
code, report it as an error.
Exportability checking logic detects when decls are referenced from API
or inlinable code. This duplicates the check applied for the access
level. Skip the exportability reports about non-public imports and keep
the more familiar access-level check.
Typealiases with an underlying type from a non-public import cannot be
used in API or inlinable code. Report this as an error.
@xymus
Copy link
Contributor Author

xymus commented Sep 26, 2023

@swift-ci Please smoke test

public import ConformanceBaseTypes
internal import ConformanceDefinition

public func useInAPI(a: any Proto = ConformingType()) { // expected-error {{cannot use conformance of 'ConformingType' to 'Proto' here; 'ConformanceDefinition' was not imported publicly}}
Copy link
Contributor

Choose a reason for hiding this comment

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

Should there be a corresponding note: on the import decl?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Very good point. I've added the note.

@xymus
Copy link
Contributor Author

xymus commented Sep 27, 2023

@swift-ci Please smoke test macOS

@xymus
Copy link
Contributor Author

xymus commented Sep 27, 2023

@swift-ci Please smoke test

@xymus xymus merged commit 1bf3686 into swiftlang:main Sep 27, 2023
@xymus xymus deleted the access-level-import-indirect-checks branch September 27, 2023 19:54
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