|
1 | 1 | // RUN: %empty-directory(%t)
|
2 | 2 | // RUN: split-file %s %t
|
3 | 3 |
|
4 |
| -/// 1. Test `@_implementationOnly import`. |
5 |
| -// RUN: %target-build-swift-dylib(%t/%target-library-name(Utils)) \ |
6 |
| -// RUN: %t/UtilsA.swift %t/UtilsB.swift \ |
7 |
| -// RUN: -module-name Utils -emit-module -package-name Pkg \ |
8 |
| -// RUN: -Xfrontend -experimental-package-cmo -Xfrontend -experimental-allow-non-resilient-access \ |
9 |
| -// RUN: -enable-library-evolution -O -wmo |
10 |
| -// RUN: %target-sil-opt %t/Utils.swiftmodule -I %t -sil-verify-all -o %t/Utils.sil |
11 |
| -// RUN: %FileCheck %s --check-prefix=CHECK-UTILS < %t/Utils.sil |
12 |
| - |
13 |
| -/// Verify accessing PkgKlass.second from a client in a dynamic context does not cause a linker error. |
14 |
| -// RUN: %target-build-swift -I %t -L %t %t/Client.swift -package-name Pkg \ |
15 |
| -// RUN: -O -wmo -enable-library-evolution \ |
16 |
| -// RUN: %target-rpath(%t) -lUtils -o %t/a.out |
17 |
| - |
18 |
| -// RUN: %target-swift-frontend -emit-sil -I %t -L %t %t/Client.swift \ |
19 |
| -// RUN: -package-name Pkg -O -wmo -enable-library-evolution \ |
20 |
| -// RUN: -lUtils -o %t/Client.sil |
21 |
| -// RUN: %FileCheck %s --check-prefix=CHECK-CLIENT < %t/Client.sil |
22 |
| - |
23 |
| -/// 2. Test `package import` and `@_spiOnly import`. |
24 | 4 | // RUN: %target-swift-frontend %t/CoreA.swift \
|
25 | 5 | // RUN: -module-name=CoreA -package-name Pkg \
|
26 | 6 | // RUN: -parse-as-library -emit-module \
|
|
33 | 13 | // RUN: -emit-module-path %t/CoreB.swiftmodule -I%t \
|
34 | 14 | // RUN: -O -wmo -enable-library-evolution
|
35 | 15 |
|
36 |
| -// RUN: %target-swift-frontend %t/UI.swift \ |
37 |
| -// RUN: -module-name=UI -package-name Pkg \ |
| 16 | +// RUN: %target-swift-frontend %t/Lib.swift \ |
| 17 | +// RUN: -module-name=Lib -package-name Pkg \ |
38 | 18 | // RUN: -parse-as-library -emit-module \
|
39 | 19 | // RUN: -experimental-spi-only-imports \
|
40 |
| -// RUN: -emit-module-path %t/UI.swiftmodule -I %t \ |
| 20 | +// RUN: -emit-module-path %t/Lib.swiftmodule -I %t \ |
41 | 21 | // RUN: -experimental-package-cmo -experimental-allow-non-resilient-access \
|
42 |
| -// RUN: -O -wmo -enable-library-evolution -Rmodule-loading 2> %t/UI-result.txt |
43 |
| -// RUN: %target-sil-opt %t/UI.swiftmodule -I %t -sil-verify-all -o %t/UI.sil |
44 |
| -// RUN: %FileCheck %s < %t/UI.sil |
| 22 | +// RUN: -O -wmo -enable-library-evolution -Rmodule-loading 2> %t/Lib-result.txt |
| 23 | +// RUN: %target-sil-opt %t/Lib.swiftmodule -I %t -sil-verify-all -o %t/Lib.sil |
| 24 | +// RUN: %FileCheck %s < %t/Lib.sil |
45 | 25 |
|
46 | 26 | // REQUIRES: swift_in_compiler
|
47 |
| -// REQUIRES: OS=macosx || OS=ios || OS=tvos || OS=watchos || OS=maccatalyst |
48 |
| - |
49 |
| -//--- Client.swift |
50 |
| -package import Utils |
51 |
| - |
52 |
| -package func clientFunc<T: PkgKlass>(_ list: [T]) { |
53 |
| - // closure #1 in clientFunc<A>(_:) |
54 |
| - // CHECK-CLIENT: sil private @$s6Client10clientFuncyySayxG5Utils8PkgKlassCRbzlFSo8NSObjectCxXEfU_ : $@convention(thin) <T where T : PkgKlass> (@in_guaranteed T) -> (@out NSObject, @error_indirect Never) { |
55 |
| - // CHECK-CLIENT: class_method {{.*}} #PkgKlass.second!getter : (PkgKlass) -> () -> NSObject, $@convention(method) (@guaranteed PkgKlass) -> @owned NSObject |
56 |
| - // CHECK-CLIENT: } // end sil function '$s6Client10clientFuncyySayxG5Utils8PkgKlassCRbzlFSo8NSObjectCxXEfU_' |
57 |
| - let result = list.map { $0.second } |
58 |
| - print(result) |
59 |
| -} |
60 |
| - |
61 |
| - |
62 |
| -//--- UtilsA.swift |
63 |
| -public import Foundation // public import to allow `NSObject` in API. |
64 | 27 |
|
65 |
| -package class PkgKlass: NSObject { |
66 |
| - /// Serialized since it does _not_ reference a type from module imported as @_implementationOnly. |
67 |
| - // PkgKlass.first.getter |
68 |
| - // CHECK-UTILS-DAG: sil package [serialized_for_package] [canonical] @$s5Utils8PkgKlassC5firstSSvg : $@convention(method) (@guaranteed PkgKlass) -> @owned String { |
69 |
| - package var first: String |
70 |
| - |
71 |
| - /// NOT serialized since it does reference a type from module imported as @_implementationOnly. |
72 |
| - // PkgKlass.second.getter |
73 |
| - // CHECK-UTILS-DAG: sil package_external [canonical] @$s5Utils8PkgKlassC6secondSo8NSObjectCvg : $@convention(method) (@guaranteed PkgKlass) -> @owned NSObject |
74 |
| - @objc package var second: NSObject |
75 |
| - |
76 |
| - init(first: String, second: NSObject) { |
77 |
| - self.first = first |
78 |
| - self.second = second |
79 |
| - } |
80 |
| -} |
81 |
| - |
82 |
| -//--- UtilsB.swift |
83 |
| -@_implementationOnly import Foundation |
84 |
| - |
85 |
| -public func utilsFunc() { |
86 |
| - let x: NSString = "utilsfunc" |
87 |
| - print(x) |
88 |
| -} |
89 | 28 |
|
90 |
| -//--- UI.swift |
| 29 | +//--- Lib.swift |
91 | 30 | package import CoreA
|
92 | 31 | @_spiOnly public import CoreB
|
93 | 32 |
|
94 | 33 | /// PkgStruct is imported with `package import` and should be serialized.
|
95 |
| -// CHECK-DAG: sil package [serialized_for_package] [canonical] @$s2UI7libFuncyy5CoreA9PkgStructVF : $@convention(thin) (@in_guaranteed PkgStruct) -> () { |
| 34 | +// CHECK-DAG: sil package [serialized_for_package] [canonical] @$s3Lib7libFuncyy5CoreA9PkgStructVF : $@convention(thin) (@in_guaranteed PkgStruct) -> () { |
96 | 35 | package func libFunc(_ arg: PkgStruct) {
|
97 | 36 | print(arg.pkgVar)
|
98 | 37 | }
|
99 | 38 |
|
100 | 39 | /// PubStruct is imported with `@_spiOnly public import` and should be serialized.
|
101 |
| -// CHECK-DAG: sil [serialized_for_package] [canonical] @$s2UI7spiFuncyy5CoreB15PubStructForSPIVF : $@convention(thin) (@in_guaranteed PubStructForSPI) -> () { |
102 |
| -@_spi(GroupB) |
| 40 | +// CHECK-DAG: sil [serialized_for_package] [canonical] @$s3Lib7spiFuncyy5CoreB15PubStructForSPIVF : $@convention(thin) (@in_guaranteed PubStructForSPI) -> () { |
| 41 | +@_spi(InCoreB) |
103 | 42 | public func spiFunc(_ arg: PubStructForSPI) {
|
104 | 43 | print(arg.pubVarForSPI)
|
105 | 44 | }
|
|
0 commit comments