Skip to content

Conversation

@sepy97
Copy link
Contributor

@sepy97 sepy97 commented Dec 15, 2025

Swift compiler allowed accessing a private setter from an @inlinable function. This change detects and diagnose it with a corresponding error.

rdar://81879146

@sepy97
Copy link
Contributor Author

sepy97 commented Dec 15, 2025

@swift-ci please smoke test

if (accessor->getAccessorKind() == AccessorKind::Set &&
accessor->getFormalAccess() == AccessLevel::Private) {
auto *storage = accessor->getStorage();
if (storage->getAttrs().hasAttribute<UsableFromInlineAttr>()) {
Copy link
Contributor

Choose a reason for hiding this comment

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

What if the storage is public? We don't want to check for this attribute directly, instead check it using access scopes like we do for everything else.

@sepy97 sepy97 force-pushed the inlinable-function-private-setter branch 2 times, most recently from 1dca620 to 6a13458 Compare December 16, 2025 18:39
@sepy97
Copy link
Contributor Author

sepy97 commented Dec 16, 2025

@swift-ci please smoke test

@sepy97 sepy97 requested a review from slavapestov December 16, 2025 18:41
@sepy97 sepy97 force-pushed the inlinable-function-private-setter branch from 6a13458 to 4ec9a06 Compare December 16, 2025 21:36
@sepy97
Copy link
Contributor Author

sepy97 commented Dec 16, 2025

@swift-ci please smoke test

@sepy97 sepy97 force-pushed the inlinable-function-private-setter branch from 4ec9a06 to 4af1a8b Compare December 16, 2025 23:22
@sepy97 sepy97 force-pushed the inlinable-function-private-setter branch from 4af1a8b to 38cbc7d Compare December 17, 2025 00:19
@sepy97
Copy link
Contributor Author

sepy97 commented Dec 17, 2025

@swift-ci please smoke test

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