Skip to content

Allow @usableFromInline and @inlinable to package decls #64408

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
Mar 17, 2023
Merged

Allow @usableFromInline and @inlinable to package decls #64408

merged 2 commits into from
Mar 17, 2023

Conversation

elsh
Copy link
Contributor

@elsh elsh commented Mar 15, 2023

Allow @usableFromInline and @inlinable to package decls
Add tests
Resolves rdar://104617133

This PR allows the following (similar to how the attributes works with internal/public decls):

@usableFromInline package func foo() {}
@inlinable package func bar() { 
    foo() 
}
@inlinable public func baz() { 
    foo() 
}

@@ -1,3 +1,4 @@
// RUN: %target-typecheck-verify-swift -package-name myPkg
Copy link
Contributor Author

@elsh elsh Mar 15, 2023

Choose a reason for hiding this comment

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

Adding this back (removed in the previous PR); changes to the existing tests in this file are needed to match the original (before the PR)

@elsh
Copy link
Contributor Author

elsh commented Mar 16, 2023

@swift-ci smoke test

Add tests for packgae inline
Add more package acl tests

Resolves rdar://104617133
@elsh
Copy link
Contributor Author

elsh commented Mar 16, 2023

@swift-ci smoke test

@elsh
Copy link
Contributor Author

elsh commented Mar 17, 2023

@swift-ci smoke test

WARNING(protocol_usable_from_inline_warn,none,
"protocol %select{refined|used}0 by '@usableFromInline' protocol "
"should be '@usableForInline' or public", (bool))
"should be '@usableFromInline' or public", (bool))
Copy link
Contributor

Choose a reason for hiding this comment

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

Good catch, I wonder how long that typo was there.

// RUN: not %target-swift-frontend -typecheck %t/Utils.swift -package-name myLib -I %t 2> %t/resultUtils.output
// RUN: %FileCheck %s -input-file %t/resultUtils.output -check-prefix CHECK-UTILS
// CHECK-UTILS: error: class 'PackageKlass' is package and cannot be referenced from an '@inlinable' function
// CHECK-UTILS: let a = PackageKlass()
Copy link
Contributor

Choose a reason for hiding this comment

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

Can we use the -verify mode and \\ expected-errors to test these? Or maybe move the CHECK lines under the source code raising it if -verify isn't an option? Having the error far from the code makes it hard to follow along.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Makes sense; will update the test in the next PR

@elsh elsh merged commit 2bc92a6 into main Mar 17, 2023
@elsh elsh deleted the es-inline branch March 17, 2023 22:34
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