|
| 1 | +/// Simple use case of a package only import. |
| 2 | + |
| 3 | +// RUN: %empty-directory(%t) |
| 4 | +// RUN: split-file %s %t |
| 5 | + |
| 6 | +/// Build the libraries. |
| 7 | +// RUN: %target-swift-frontend -emit-module %t/PackageImportedLib.swift -o %t \ |
| 8 | +// RUN: -swift-version 5 -enable-library-evolution \ |
| 9 | +// RUN: -enable-experimental-feature AccessLevelOnImport |
| 10 | +// RUN: %target-swift-frontend -emit-module %t/PackageLib.swift -o %t \ |
| 11 | +// RUN: -swift-version 5 -enable-library-evolution -I %t \ |
| 12 | +// RUN: -enable-experimental-feature AccessLevelOnImport \ |
| 13 | +// RUN: -package-name MyPackage |
| 14 | + |
| 15 | +/// A client in the same package builds fine. |
| 16 | +// RUN: %target-swift-frontend -typecheck %t/Client.swift -I %t \ |
| 17 | +// RUN: -package-name MyPackage -I %t \ |
| 18 | +// RUN: -enable-experimental-feature AccessLevelOnImport |
| 19 | + |
| 20 | +/// A client outside of the package raises errors. |
| 21 | +// RUN: %target-swift-frontend -typecheck %t/Client.swift -I %t \ |
| 22 | +// RUN: -package-name NotMyPackage -I %t \ |
| 23 | +// RUN: -enable-experimental-feature AccessLevelOnImport -verify |
| 24 | + |
| 25 | +//--- PackageImportedLib.swift |
| 26 | +public struct IndirectType { |
| 27 | + public init() {} |
| 28 | + public func someMethod() {} |
| 29 | +} |
| 30 | +public protocol IndirectProtocol {} |
| 31 | + |
| 32 | +//--- PackageLib.swift |
| 33 | +package import PackageImportedLib |
| 34 | + |
| 35 | +package func getIndirectType() -> IndirectType { |
| 36 | + return IndirectType() |
| 37 | +} |
| 38 | + |
| 39 | +package func packageFunc(a: IndirectType) { |
| 40 | +} |
| 41 | + |
| 42 | +package struct PackageStruct : IndirectProtocol { |
| 43 | + package init() {} |
| 44 | + |
| 45 | + package var a = IndirectType() |
| 46 | +} |
| 47 | + |
| 48 | +//--- Client.swift |
| 49 | +public import PackageLib |
| 50 | + |
| 51 | +let t = getIndirectType() // expected-error {{cannot find 'getIndirectType' in scope}} |
| 52 | +t.someMethod() |
| 53 | +packageFunc(a: t) // expected-error {{cannot find 'packageFunc' in scope}} |
| 54 | + |
| 55 | +let s = PackageStruct() // expected-error {{cannot find 'PackageStruct' in scope}} |
| 56 | +s.a.someMethod() |
0 commit comments