Skip to content

[Sema] Treat @usableFromInline package decls from interface as public and skip access checks #75745

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 2 commits into from
Aug 14, 2024

Conversation

elsh
Copy link
Contributor

@elsh elsh commented Aug 7, 2024

If a package decl has a @usableFromInline (or other inlinable) attribute, and is defined in a module built from interface, it
can be referenced by another module that imports it even though the defining interface module does not have package-name (such as public or private interface with -disable-print-package-name-for-non-package-interface); in such case, type check on the decl fails due to the missing package-name. This PR treats the decl as public and skip type/access checks.

Resolves rdar://133319906

@elsh elsh requested review from artemcm and tshortli as code owners August 7, 2024 03:37
@elsh elsh requested a review from nkcsgexi August 7, 2024 03:37
@elsh elsh force-pushed the elsh/pkg-name-interface branch from 153d64a to a4861ef Compare August 7, 2024 03:38
@elsh
Copy link
Contributor Author

elsh commented Aug 7, 2024

@swift-ci smoke test

@elsh
Copy link
Contributor Author

elsh commented Aug 7, 2024

@swift-ci smoke test

@elsh elsh force-pushed the elsh/pkg-name-interface branch from 2afcaa2 to 9c3eca9 Compare August 13, 2024 20:33
@elsh elsh requested a review from AnthonyLatsis as a code owner August 13, 2024 20:33
@elsh elsh changed the title [PackageInterface] Only print package-name in package.swiftinterface by default. [Sema] Treat @usableFromInline package decls from interface as public and skip access checks Aug 13, 2024
@elsh
Copy link
Contributor Author

elsh commented Aug 13, 2024

@swift-ci smoke test

/// - Has a @usableFromInline (or other inlinable) attribute
/// - And is defined in a module built from a public or private
/// interface that does not contain package-name.
bool treatAsPublic() const;
Copy link
Contributor

Choose a reason for hiding this comment

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

This name reads a bit too generically to me - if I hadn't read the documentation I wouldn't know what it represents at its use sites. What about something like hasEffectivelyPublicPackageAccess()?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Sg, probably hasEffectivelyPublicAccess().

Copy link
Contributor

Choose a reason for hiding this comment

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

I think it should mention package somehow because it's only meant to be called when you've already determined that the decl has package level access. I would find it confusing if hasEffectivelyPublicAccess() returns false for a decl that is already marked public for example.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

How about isPackageEffectivelyPublic?

Copy link
Contributor

Choose a reason for hiding this comment

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

That's better, though it feels like it's missing an And or a But, e.g. isPackageButEffectivelyPublic.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

To be more concrete, it could be isInterfacePackageEffectivelyPublic.

… and skip access checks

Resolves rdar://133319906
@elsh elsh force-pushed the elsh/pkg-name-interface branch from e7f9433 to dc1c34d Compare August 14, 2024 00:01
@elsh
Copy link
Contributor Author

elsh commented Aug 14, 2024

@swift-ci smoke test

@elsh elsh enabled auto-merge August 14, 2024 08:35
@elsh elsh merged commit 14b8ab6 into main Aug 14, 2024
3 checks passed
@elsh elsh deleted the elsh/pkg-name-interface branch August 14, 2024 12:04
tshortli added a commit to tshortli/swift that referenced this pull request Nov 5, 2024
Finishes resolving rdar://139236053.
tshortli added a commit to tshortli/swift that referenced this pull request Nov 5, 2024
After reverting swiftlang#75745 some expectations
needed to change in this 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.

3 participants