Skip to content

Commit 2b5fc3a

Browse files
committed
[SPI Test] Test how modules can expose imported SPI through their SPI
1 parent 480e893 commit 2b5fc3a

File tree

1 file changed

+29
-0
lines changed

1 file changed

+29
-0
lines changed

test/SPI/client_reuse_spi.swift

Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
/// A module should be able to leak SPI types from an import through SPI decls
2+
3+
// RUN: %empty-directory(%t)
4+
// RUN: %target-swift-frontend -emit-module -DLIB_A %s -module-name A -emit-module-path %t/A.swiftmodule
5+
// RUN: %target-swift-frontend -emit-module -DLIB_B %s -module-name B -emit-module-path %t/B.swiftmodule -I %t
6+
// RUN: %target-swift-frontend -typecheck -verify -verify-ignore-unknown -DLIB_C %s -I %t
7+
8+
#if LIB_A
9+
10+
@_spi(A) public struct SecretStruct {
11+
@_spi(A) public func bar() {}
12+
}
13+
14+
#elseif LIB_B
15+
16+
@_spi(A) import A
17+
18+
@_spi(B) public func foo() -> SecretStruct { fatalError() }
19+
20+
#elseif LIB_C
21+
22+
@_spi(B) import B
23+
24+
var a = foo() // OK
25+
a.bar() // expected-error{{'bar' is inaccessible due to '@_spi' protection level}}
26+
27+
var b = SecretStruct() // expected-error{{use of unresolved identifier}}
28+
29+
#endif

0 commit comments

Comments
 (0)