|
2 | 2 | // RUN: %target-typecheck-verify-swift -swift-version 5 -disable-objc-attr-requires-foundation-module -enable-objc-interop -enable-testing -package-name myPkg |
3 | 3 |
|
4 | 4 | @usableFromInline private func privateVersioned() {} |
5 | | -// expected-error@-1 {{'@usableFromInline' attribute can only be applied to internal or package declarations, but 'privateVersioned()' is private}} |
| 5 | +// expected-error@-1 {{'@usableFromInline' attribute can only be applied to internal or package declarations, but global function 'privateVersioned()' is private}} |
6 | 6 |
|
7 | 7 | @usableFromInline fileprivate func fileprivateVersioned() {} |
8 | | -// expected-error@-1 {{'@usableFromInline' attribute can only be applied to internal or package declarations, but 'fileprivateVersioned()' is fileprivate}} |
| 8 | +// expected-error@-1 {{'@usableFromInline' attribute can only be applied to internal or package declarations, but global function 'fileprivateVersioned()' is fileprivate}} |
9 | 9 |
|
10 | 10 | @usableFromInline internal func internalVersioned() {} |
11 | 11 | // OK |
|
17 | 17 | // OK |
18 | 18 |
|
19 | 19 | @usableFromInline public func publicVersioned() {} |
20 | | -// expected-error@-1 {{'@usableFromInline' attribute can only be applied to internal or package declarations, but 'publicVersioned()' is public}} |
| 20 | +// expected-error@-1 {{'@usableFromInline' attribute can only be applied to internal or package declarations, but global function 'publicVersioned()' is public}} |
21 | 21 |
|
22 | 22 | // expected-note@+1 3{{global function 'internalFunc()' is not '@usableFromInline' or public}} |
23 | 23 | internal func internalFunc() {} |
@@ -55,13 +55,13 @@ package func packageInlinableFunc() { |
55 | 55 | package class PackageClass { |
56 | 56 | // expected-note@-1 *{{type declared here}} |
57 | 57 | @usableFromInline public func publicVersioned() {} |
58 | | - // expected-error@-1 {{'@usableFromInline' attribute can only be applied to internal or package declarations, but 'publicVersioned()' is public}} |
| 58 | + // expected-error@-1 {{'@usableFromInline' attribute can only be applied to internal or package declarations, but instance method 'publicVersioned()' is public}} |
59 | 59 | } |
60 | 60 |
|
61 | 61 | internal class InternalClass { |
62 | 62 | // expected-note@-1 2{{type declared here}} |
63 | 63 | @usableFromInline public func publicVersioned() {} |
64 | | - // expected-error@-1 {{'@usableFromInline' attribute can only be applied to internal or package declarations, but 'publicVersioned()' is public}} |
| 64 | + // expected-error@-1 {{'@usableFromInline' attribute can only be applied to internal or package declarations, but instance method 'publicVersioned()' is public}} |
65 | 65 | } |
66 | 66 |
|
67 | 67 | fileprivate class filePrivateClass { |
@@ -334,3 +334,21 @@ public struct TestGenericSubscripts { |
334 | 334 | @usableFromInline package func pkgNonGenericWhereClause() where T : PackageProtocol {} |
335 | 335 | // expected-error@-1 {{type referenced from a generic requirement of a '@usableFromInline' instance method must be '@usableFromInline' or public}} |
336 | 336 | } |
| 337 | + |
| 338 | +public struct IncorrectInitUse { |
| 339 | + public var x: Int { |
| 340 | + @usableFromInline |
| 341 | + // expected-error@-1 {{'@usableFromInline' attribute can only be applied to internal or package declarations, but getter for property 'x' is public}} |
| 342 | + get { 0 } |
| 343 | + |
| 344 | + @usableFromInline |
| 345 | + // expected-error@-1 {{'@usableFromInline' attribute can only be applied to internal or package declarations, but setter for property 'x' is public}} |
| 346 | + set { } |
| 347 | + } |
| 348 | + |
| 349 | + @usableFromInline |
| 350 | + // expected-error@-1 {{'@usableFromInline' attribute can only be applied to internal or package declarations, but initializer 'init(x:)' is public}} |
| 351 | + public init(x: Int) { |
| 352 | + self.x = x |
| 353 | + } |
| 354 | +} |
0 commit comments