|
| 1 | +/// Test the generated private textual module interfaces and that the public |
| 2 | +/// one doesn't leak SPI decls and info. |
| 3 | + |
| 4 | +// RUN: %empty-directory(%t) |
| 5 | +// RUN: %target-swift-frontend -emit-module %S/Inputs/spi_helper.swift -module-name SPIHelper -emit-module-path %t/SPIHelper.swiftmodule -swift-version 5 -enable-library-evolution -emit-module-interface-path %t/SPIHelper.swiftinterface -emit-private-module-interface-path %t/SPIHelper.private.swiftinterface |
| 6 | + |
| 7 | +/// Make sure that the public swiftinterface of spi_helper doesn't leak SPI. |
| 8 | +// RUN: %FileCheck -check-prefix=CHECK-HELPER %s < %t/SPIHelper.swiftinterface |
| 9 | +// CHECK-HELPER-NOT: HelperSPI |
| 10 | +// CHECK-HELPER-NOT: @_spi |
| 11 | + |
| 12 | +/// Test the textual interfaces generated from this test. |
| 13 | +// RUN: %target-swift-frontend -typecheck %s -emit-module-interface-path %t/main.swiftinterface -emit-private-module-interface-path %t/main.private.swiftinterface -enable-library-evolution -swift-version 5 -I %t |
| 14 | +// RUN: %FileCheck -check-prefix=CHECK-PUBLIC %s < %t/main.swiftinterface |
| 15 | +// RUN: %FileCheck -check-prefix=CHECK-PRIVATE %s < %t/main.private.swiftinterface |
| 16 | + |
| 17 | +/// Serialize and deserialize this module, then print. |
| 18 | +// RUN: %target-swift-frontend -emit-module %s -emit-module-path %t/merged-partial.swiftmodule -swift-version 5 -I %t -module-name merged -enable-library-evolution |
| 19 | +// RUN: %target-swift-frontend -merge-modules %t/merged-partial.swiftmodule -module-name merged -sil-merge-partial-modules -emit-module -emit-module-path %t/merged.swiftmodule -I %t -emit-module-interface-path %t/merged.swiftinterface -emit-private-module-interface-path %t/merged.private.swiftinterface -enable-library-evolution -swift-version 5 -I %t |
| 20 | +// RUN: %FileCheck -check-prefix=CHECK-PUBLIC %s < %t/merged.swiftinterface |
| 21 | +// RUN: %FileCheck -check-prefix=CHECK-PRIVATE %s < %t/merged.private.swiftinterface |
| 22 | + |
| 23 | +@_spi(HelperSPI) @_spi(OtherSPI) import SPIHelper |
| 24 | +// CHECK-PUBLIC: import SPIHelper |
| 25 | +// CHECK-PRIVATE: @_spi(OtherSPI) @_spi(HelperSPI) import SPIHelper |
| 26 | + |
| 27 | +public func foo() {} |
| 28 | +// CHECK-PUBLIC: foo() |
| 29 | +// CHECK-PRIVATE: foo() |
| 30 | + |
| 31 | +@_spi(MySPI) @_spi(MyOtherSPI) public func localSPIFunc() {} |
| 32 | +// CHECK-PRIVATE: @_spi(MySPI) |
| 33 | +// CHECK-PRIVATE: localSPIFunc() |
| 34 | +// CHECK-PUBLIC-NOT: localSPIFunc() |
| 35 | + |
| 36 | +// SPI declarations |
| 37 | +@_spi(MySPI) public class SPIClassLocal {} |
| 38 | +// CHECK-PRIVATE: @_spi(MySPI) public class SPIClassLocal |
| 39 | +// CHECK-PUBLIC-NOT: class SPIClassLocal |
| 40 | + |
| 41 | +@_spi(MySPI) public extension SPIClassLocal { |
| 42 | +// CHECK-PRIVATE: @_spi(MySPI) extension SPIClassLocal |
| 43 | +// CHECK-PUBLIC-NOT: extension SPIClassLocal |
| 44 | + |
| 45 | + @_spi(MySPI) func extensionMethod() {} |
| 46 | + // CHECK-PRIVATE: @_spi(MySPI) public func extensionMethod |
| 47 | + // CHECK-PUBLIC-NOT: func extensionMethod |
| 48 | + |
| 49 | + func internalExtensionMethod() {} |
| 50 | + // CHECK-PRIVATE-NOT: internalExtensionMethod |
| 51 | + // CHECK-PUBLIC-NOT: internalExtensionMethod |
| 52 | +} |
| 53 | + |
| 54 | +class InternalClassLocal {} |
| 55 | +// CHECK-PRIVATE-NOT: InternalClassLocal |
| 56 | +// CHECK-PUBLIC-NOT: InternalClassLocal |
| 57 | + |
| 58 | +private class PrivateClassLocal {} |
| 59 | +// CHECK-PRIVATE-NOT: PrivateClassLocal |
| 60 | +// CHECK-PUBLIC-NOT: PrivateClassLocal |
| 61 | + |
| 62 | +@_spi(LocalSPI) public func useOfSPITypeOk(_ p: SPIClassLocal) -> SPIClassLocal { |
| 63 | + fatalError() |
| 64 | +} |
| 65 | +// CHECK-PRIVATE: @_spi(LocalSPI) public func useOfSPITypeOk |
| 66 | +// CHECK-PUBLIC-NOT: useOfSPITypeOk |
| 67 | + |
| 68 | +@_spi(LocalSPI) extension SPIClass { |
| 69 | + // CHECK-PRIVATE: @_spi(LocalSPI) extension SPIClass |
| 70 | + // CHECK-PUBLIC-NOT: SPIClass |
| 71 | + |
| 72 | + @_spi(LocalSPI) public func extensionSPIMethod() {} |
| 73 | + // CHECK-PRIVATE: @_spi(LocalSPI) public func extensionSPIMethod() |
| 74 | + // CHECK-PUBLIC-NOT: extensionSPIMethod |
| 75 | +} |
0 commit comments