|
4 | 4 | // RUN: split-file --leading-lines %s %t
|
5 | 5 |
|
6 | 6 | /// Build the libraries.
|
7 |
| -// RUN: %target-swift-frontend -emit-module %t/PublicLib.swift -o %t |
8 |
| -// RUN: %target-swift-frontend -emit-module %t/PackageLib.swift -o %t |
| 7 | +// RUN: %target-swift-frontend -emit-module %t/PublicLib.swift -o %t \ |
| 8 | +// RUN: -package-name pkg |
| 9 | +// RUN: %target-swift-frontend -emit-module %t/PackageLib.swift -o %t \ |
| 10 | +// RUN: -package-name pkg |
9 | 11 | // RUN: %target-swift-frontend -emit-module %t/InternalLib.swift -o %t
|
10 | 12 | // RUN: %target-swift-frontend -emit-module %t/FileprivateLib.swift -o %t
|
11 | 13 | // RUN: %target-swift-frontend -emit-module %t/PrivateLib.swift -o %t
|
|
14 | 16 | // RUN: %target-swift-frontend -typecheck %t/Client.swift -I %t \
|
15 | 17 | // RUN: -enable-experimental-feature AccessLevelOnImport -verify \
|
16 | 18 | // RUN: -package-name pkg
|
| 19 | +// RUN: %target-swift-frontend -typecheck %t/PackageTypeImportedAsPackageClient.swift -I %t \ |
| 20 | +// RUN: -enable-experimental-feature AccessLevelOnImport -verify \ |
| 21 | +// RUN: -package-name pkg |
17 | 22 | // RUN: %target-swift-frontend -typecheck %t/LocalVsImportClient.swift -I %t \
|
18 | 23 | // RUN: -enable-experimental-feature AccessLevelOnImport -verify \
|
19 | 24 | // RUN: -package-name pkg
|
20 | 25 |
|
21 | 26 | //--- PublicLib.swift
|
22 | 27 | public struct PublicImportType {}
|
| 28 | +package struct PackageLevelPublicImportedType {} |
23 | 29 |
|
24 | 30 | //--- PackageLib.swift
|
25 | 31 | public struct PackageImportType {}
|
| 32 | +package struct PackageLevelPackageImportedType {} |
26 | 33 |
|
27 | 34 | //--- InternalLib.swift
|
28 | 35 | public struct InternalImportType {}
|
@@ -62,6 +69,26 @@ public func publicFuncUsesPrivateScambled(_ a: PublicImportType, d: FileprivateI
|
62 | 69 | var _: PrivateImportType
|
63 | 70 | }
|
64 | 71 |
|
| 72 | +//--- PackageTypeImportedAsPackageClient.swift |
| 73 | +/// Report errors about using package decls in public but don't note the import |
| 74 | +/// as it doesn't affect the access level of the decls. |
| 75 | + |
| 76 | +public import PublicLib |
| 77 | +package import PackageLib |
| 78 | + |
| 79 | +public func publicFuncUsesPackageLevelPublicImportedType(_ a: PackageLevelPublicImportedType) {} // expected-error {{function cannot be declared public because its parameter uses a package type}} |
| 80 | +public func publicFuncUsesPackageLevelPackageImportedType(_ a: PackageLevelPackageImportedType) {} // expected-error {{function cannot be declared public because its parameter uses a package type}} |
| 81 | + |
| 82 | +@inlinable public func funcInlinableReferenceToPublicImportedType() { |
| 83 | + var _: PackageLevelPublicImportedType // expected-error {{struct 'PackageLevelPublicImportedType' is package and cannot be referenced from an '@inlinable' function}} |
| 84 | + var _: Array<PackageLevelPublicImportedType> // expected-error {{struct 'PackageLevelPublicImportedType' is package and cannot be referenced from an '@inlinable' function}} |
| 85 | +} |
| 86 | + |
| 87 | +@inlinable public func funcInlinableReferenceToPackageImportedType() { |
| 88 | + var _: PackageLevelPackageImportedType // expected-error {{struct 'PackageLevelPackageImportedType' is package and cannot be referenced from an '@inlinable' function}} |
| 89 | + var _: Array<PackageLevelPackageImportedType> // expected-error {{struct 'PackageLevelPackageImportedType' is package and cannot be referenced from an '@inlinable' function}} |
| 90 | +} |
| 91 | + |
65 | 92 | /// Local vs imports
|
66 | 93 | //--- LocalVsImportClient.swift
|
67 | 94 | public import PublicLib
|
|
0 commit comments