Skip to content

Embedded: Accept and enforce @_implementationOnly class properties#88078

Merged
xymus merged 2 commits into
swiftlang:mainfrom
xymus:exportability-embedded-class-properties
Apr 7, 2026
Merged

Embedded: Accept and enforce @_implementationOnly class properties#88078
xymus merged 2 commits into
swiftlang:mainfrom
xymus:exportability-embedded-class-properties

Conversation

@xymus
Copy link
Copy Markdown
Contributor

@xymus xymus commented Mar 24, 2026

When hiding dependencies in embedded mode there are special rules for classes. Classes properties can safely reference the hidden dependencies, however code referencing these properties must be marked @export(interface).

We previously added a check to report implicit code without the requited @export(interface) in #87582 and #87992. However explicit references from user written code wasn't fully checked, only explicit references to the imported type or the type's services would be reported, not references to the property itself.

We patch that hole here by introducing new requirements and a new layer of check specific to class properies in embedded mode.


Class properties referencing a hidden dependency must be marked @_implementationOnly. This adds on top of the requirement for the class itself to have an explicit @export(interface) deinit.

This allows to report references from user written code using existing diagnostics.

When hiding dependencies in embedded mode there are special rules for
classes. Classes properties can safely reference the hidden
dependencies, however code referencing these properties must be marked
`@export(interface)`.

We previously added a check to report implicit code without the requited
`@export(interface)`. However explicit references from user written code
wasn't fully checked, only explicit references to the imported type or
the type's services would be reported, not references to the property
itself.

We patch that hole here by introducing new requirements and a new layer
of check specific to class properies in embedded mode.

---

Class properties referencing a hidden dependency must be marked
`@_implementationOnly`. This adds on top of the requirement for the
class itself to have an explicit `@export(interface) deinit`.

This allows to report references from user written code using existing
diagnostics.
@xymus
Copy link
Copy Markdown
Contributor Author

xymus commented Mar 24, 2026

@swift-ci Please smoke test

@xymus
Copy link
Copy Markdown
Contributor Author

xymus commented Mar 25, 2026

@swift-ci Please smoke test macOS

@xymus
Copy link
Copy Markdown
Contributor Author

xymus commented Mar 25, 2026

@swift-ci Please smoke test Windows

1 similar comment
@xymus
Copy link
Copy Markdown
Contributor Author

xymus commented Mar 25, 2026

@swift-ci Please smoke test Windows

@xymus
Copy link
Copy Markdown
Contributor Author

xymus commented Apr 6, 2026

@swift-ci Please smoke test

@xymus xymus requested a review from a team as a code owner April 7, 2026 15:36
@xymus
Copy link
Copy Markdown
Contributor Author

xymus commented Apr 7, 2026

@swift-ci Please smoke test

@xymus xymus merged commit 89c77d9 into swiftlang:main Apr 7, 2026
3 checks passed
@xymus xymus deleted the exportability-embedded-class-properties branch April 7, 2026 20:19
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