Skip to content

Commit efbe393

Browse files
authored
Merge pull request #71778 from apple/es-pkgint
Re-enable package interface test.
2 parents 6636471 + edc5aba commit efbe393

File tree

1 file changed

+77
-70
lines changed

1 file changed

+77
-70
lines changed

test/ModuleInterface/package_interface.swift

Lines changed: 77 additions & 70 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,3 @@
1-
// rdar://118461385 (Swift CI: failing on the ASAN bot with `Abort trap: 6`)
2-
// REQUIRES: rdar118461385
3-
41
// RUN: %empty-directory(%t)
52
// RUN: split-file %s %t
63

@@ -20,64 +17,6 @@
2017
// RUN: %FileCheck --check-prefixes=CHECK,CHECK-PRIV %s < %t/Bar.private.swiftinterface
2118
// RUN: %FileCheck --check-prefixes=CHECK,CHECK-PRIV,CHECK-PKG %s < %t/Bar.package.swiftinterface
2219

23-
/// Client should load a package interface module if enabled with -experimental-package-interface-load
24-
// RUN: %target-swift-frontend -typecheck %t/Client.swift -I %t \
25-
// RUN: -package-name barpkg \
26-
// RUN: -experimental-package-interface-load \
27-
// RUN: -Rmodule-loading 2> %t/load-pkg-flag.output
28-
// RUN: %FileCheck -check-prefix=CHECK-LOAD-PKG-ENABLED %s < %t/load-pkg-flag.output
29-
30-
/// Client should load a package interface module if enabled with env var `SWIFT_ENABLE_PACKAGE_INTERFACE_LOAD`
31-
// RUN: env SWIFT_ENABLE_PACKAGE_INTERFACE_LOAD=true \
32-
// RUN: %target-swift-frontend -typecheck %t/Client.swift -I %t \
33-
// RUN: -package-name barpkg \
34-
// RUN: -Rmodule-loading 2> %t/load-pkg-env-var.output
35-
// RUN: %FileCheck -check-prefix=CHECK-LOAD-PKG-ENABLED %s < %t/load-pkg-env-var.output
36-
37-
// CHECK-LOAD-PKG-ENABLED: loaded module 'Bar'; source: '{{.*}}Bar.package.swiftinterface', loaded: '{{.*}}Bar-{{.*}}.swiftmodule'
38-
39-
/// Client should not load a package interface module without the flag or the env var
40-
// RUN: not %target-swift-frontend -typecheck %t/Client.swift -I %t \
41-
// RUN: -package-name barpkg \
42-
// RUN: -Rmodule-loading 2> %t/load-pkg-off.output
43-
// RUN: %FileCheck -check-prefix=CHECK-LOAD-PKG-OFF %s < %t/load-pkg-off.output
44-
// CHECK-LOAD-PKG-OFF: loaded module 'Bar'; source: '{{.*}}Bar.private.swiftinterface', loaded: '{{.*}}Bar-{{.*}}.swiftmodule'
45-
// CHECK-LOAD-PKG-OFF: error: module 'Bar' is in package 'barpkg' but was built from a non-package interface; modules of the same package can only be loaded if built from source or package interface: {{.*}}Bar.private.swiftinterface
46-
47-
/// Client loads a private interface since the package-name is different from the loaded module's.
48-
// RUN: %target-swift-frontend -typecheck %t/Client.swift -I %t \
49-
// RUN: -package-name foopkg \
50-
// RUN: -experimental-package-interface-load \
51-
// RUN: -Rmodule-loading 2> %t/load-diff-pkg.output
52-
// RUN: %FileCheck -check-prefix=CHECK-LOAD-DIFF-PKG %s < %t/load-diff-pkg.output
53-
// CHECK-LOAD-DIFF-PKG: loaded module 'Bar'; source: '{{.*}}Bar.private.swiftinterface', loaded: '{{.*}}Bar-{{.*}}.swiftmodule'
54-
55-
// RUN: rm -rf %t/*.swiftmodule
56-
// RUN: rm -rf %t/Bar.package.swiftinterface
57-
58-
/// Client loads a private interface since package interface doesn't exist. It should error since the loaded module is not built from a package interface.
59-
// RUN: not %target-swift-frontend -typecheck %t/Client.swift -I %t \
60-
// RUN: -package-name barpkg \
61-
// RUN: -experimental-package-interface-load \
62-
// RUN: -Rmodule-loading 2> %t/load-priv.output
63-
// RUN: %FileCheck -check-prefix=CHECK-LOAD-PRIV %s < %t/load-priv.output
64-
// CHECK-LOAD-PRIV: loaded module 'Bar'; source: '{{.*}}Bar.private.swiftinterface', loaded: '{{.*}}Bar-{{.*}}.swiftmodule'
65-
// CHECK-LOAD-PRIV: error: module 'Bar' is in package 'barpkg' but was built from a non-package interface; modules of the same package can only be loaded if built from source or package interface: {{.*}}Bar.private.swiftinterface
66-
67-
// RUN: rm -rf %t/*.swiftmodule
68-
// RUN: rm -rf %t/Bar.private.swiftinterface
69-
70-
/// Client loads a public interface since package or private interface doesn't exist.
71-
/// It should error since the loaded module is not built from a package interface.
72-
// RUN: not %target-swift-frontend -typecheck %t/Client.swift -I %t \
73-
// RUN: -package-name barpkg \
74-
// RUN: -experimental-package-interface-load \
75-
// RUN: -Rmodule-loading 2> %t/load-pub.output
76-
77-
// RUN: %FileCheck -check-prefix=CHECK-LOAD-PUB %s < %t/load-pub.output
78-
// CHECK-LOAD-PUB: loaded module 'Bar'; source: '{{.*}}Bar.swiftinterface', loaded: '{{.*}}Bar-{{.*}}.swiftmodule'
79-
// CHECK-LOAD-PUB: error: module 'Bar' is in package 'barpkg' but was built from a non-package interface; modules of the same package can only be loaded if built from source or package interface: {{.*}}Bar.swiftinterface
80-
8120

8221
//--- Bar.swift
8322
public enum PubEnum {
@@ -94,6 +33,29 @@ public enum PubEnum {
9433
// CHECK: }
9534
// CHECK: }
9635

36+
@_transparent
37+
public func pubFunc(arg: PubEnum) {
38+
switch arg {
39+
case .red:
40+
print("r")
41+
case .green:
42+
print("g")
43+
@unknown default:
44+
print("def")
45+
}
46+
}
47+
48+
// CHECK: @_transparent public func pubFunc(arg: Bar.PubEnum) {
49+
// CHECK: switch arg {
50+
// CHECK: case .red:
51+
// CHECK: print("r")
52+
// CHECK: case .green:
53+
// CHECK: print("g")
54+
// CHECK: @unknown default:
55+
// CHECK: print("def")
56+
// CHECK: }
57+
// CHECK: }
58+
9759
package enum PkgEnum {
9860
case blue, yellow
9961
}
@@ -107,6 +69,48 @@ package enum PkgEnum {
10769
// CHECK-PKG: }
10870
// CHECK-PKG: }
10971

72+
73+
@usableFromInline
74+
package enum UfiPkgEnum {
75+
case one, two
76+
}
77+
78+
// CHECK: @usableFromInline
79+
// CHECK: package enum UfiPkgEnum {
80+
// CHECK: case one, two
81+
// CHECK: @usableFromInline
82+
// CHECK: package static func == (a: Bar.UfiPkgEnum, b: Bar.UfiPkgEnum) -> Swift.Bool
83+
// CHECK: @usableFromInline
84+
// CHECK: package func hash(into hasher: inout Swift.Hasher)
85+
// CHECK: @usableFromInline
86+
// CHECK: package var hashValue: Swift.Int {
87+
// CHECK: @usableFromInline
88+
// CHECK: get
89+
// CHECK: }
90+
// CHECK: }
91+
92+
@inlinable
93+
package func pkgFunc(arg: UfiPkgEnum) {
94+
switch arg {
95+
case .one:
96+
print("1")
97+
case .two:
98+
print("2")
99+
@unknown default:
100+
print("def")
101+
}
102+
}
103+
// CHECK: @inlinable package func pkgFunc(arg: Bar.UfiPkgEnum) {
104+
// CHECK: switch arg {
105+
// CHECK: case .one:
106+
// CHECK: print("1")
107+
// CHECK: case .two:
108+
// CHECK: print("2")
109+
// CHECK: @unknown default:
110+
// CHECK: print("def")
111+
// CHECK: }
112+
// CHECK: }
113+
110114
@frozen public struct FrozenPub {
111115
public var one: String
112116
var two: String // expected to be printed in public .swiftinterface since contained in @frozen
@@ -135,9 +139,7 @@ package struct PkgStruct {
135139

136140
// CHECK-PKG: package struct PkgStruct {
137141
// CHECK-PKG: package var one: Swift.String
138-
// CHECK-PKG: internal var two: Swift.String
139-
// CHECK-PKG: private var three: Swift.String
140-
// CHECK-PKG: @_hasStorage package var four: Swift.String {
142+
// CHECK-PKG: package var four: Swift.String {
141143
// CHECK-PKG: get
142144
// CHECK-PKG: }
143145
// CHECK-PKG: }
@@ -160,6 +162,7 @@ public class PubKlass {
160162

161163
// CHECK: public class PubKlass {
162164
// CHECK: public var pubVarInPub: Swift.String
165+
// CHECK-PKG: package var pkgVarInPub: Swift.String
163166
// CHECK: public var pubVarPrivSetInPub: Swift.Int {
164167
// CHECK: get
165168
// CHECK: }
@@ -189,8 +192,7 @@ package class PkgKlass {
189192

190193
// CHECK-PKG: package class PkgKlass {
191194
// CHECK-PKG: package var pkgVarInPkg: Swift.String
192-
// CHECK-PKG: internal var intrnVarInPkg: Swift.String
193-
// CHECK-PKG: @_hasStorage package var pkgVarPrivSetInPkg: Swift.Int {
195+
// CHECK-PKG: package var pkgVarPrivSetInPkg: Swift.Int {
194196
// CHECK-PKG: get
195197
// CHECK-PKG: }
196198
// CHECK-PKG: package init()
@@ -234,6 +236,9 @@ extension PubProto {
234236
// CHECK: public var p3: Swift.Int {
235237
// CHECK: get
236238
// CHECK: }
239+
// CHECK-PKG: package var p4: Swift.Int {
240+
// CHECK-PKG: get
241+
// CHECK-PKG: }
237242
// CHECK: public func f3()
238243
// CHECK: }
239244

@@ -274,20 +279,22 @@ extension PkgProto {
274279

275280
public func pub(x: Int, y: String) { print("pub func") }
276281
// CHECK: public func pub(x: Swift.Int, y: Swift.String)
282+
277283
@_spi(LibBar) public func spi(x: Int, y: String) { print("spi func") }
278284
// CHECK-PRIV: @_spi(LibBar) public func spi(x: Swift.Int, y: Swift.String)
279-
@usableFromInline package func ufipkg(x: Int, y: String) { print("ufi pkg func") }
285+
286+
@usableFromInline
287+
package func ufipkg(x: Int, y: String) { print("ufi pkg func") }
280288
// CHECK: @usableFromInline
281289
// CHECK: package func ufipkg(x: Swift.Int, y: Swift.String)
282290

283291
package func pkg(x: Int, y: String) { print("pkg func") }
292+
// CHECK-PKG: package func pkg(x: Swift.Int, y: Swift.String)
293+
284294
func int(x: Int, y: String) { print("int func") }
285295
private func priv(x: Int, y: String) { print("priv func") }
286296

287297
// CHECK: extension Bar.PubEnum : Swift.Equatable {}
288298
// CHECK: extension Bar.PubEnum : Swift.Hashable {}
289299
// CHECK: extension Bar.FrozenPub : Swift.Sendable {}
290300

291-
292-
//--- Client.swift
293-
import Bar

0 commit comments

Comments
 (0)