|
| 1 | +/// Test the swiftinterfaces and @_spiOnly. |
| 2 | + |
| 3 | +// RUN: %empty-directory(%t) |
| 4 | +// RUN: split-file %s %t |
| 5 | + |
| 6 | +/// Generate dependencies |
| 7 | +// RUN: %target-swift-frontend -emit-module %S/Inputs/ioi_helper.swift \ |
| 8 | +// RUN: -module-name A_SPIOnlyImported -emit-module-path %t/A_SPIOnlyImported.swiftmodule |
| 9 | +// RUN: %target-swift-frontend -emit-module %t/Empty.swift \ |
| 10 | +// RUN: -module-name ConstantSPIOnly -emit-module-path %t/ConstantSPIOnly.swiftmodule |
| 11 | +// RUN: %target-swift-frontend -emit-module %t/Empty.swift \ |
| 12 | +// RUN: -module-name InconsistentIOI -emit-module-path %t/InconsistentIOI.swiftmodule |
| 13 | +// RUN: %target-swift-frontend -emit-module %t/Empty.swift \ |
| 14 | +// RUN: -module-name InconsistentPublic -emit-module-path %t/InconsistentPublic.swiftmodule |
| 15 | +// RUN: %target-swift-frontend -emit-module %t/Empty.swift \ |
| 16 | +// RUN: -module-name IOIImported -emit-module-path %t/IOIImported.swiftmodule |
| 17 | +// RUN: %target-swift-frontend -emit-module %t/Empty.swift \ |
| 18 | +// RUN: -module-name SPIImported -emit-module-path %t/SPIImported.swiftmodule |
| 19 | + |
| 20 | +/// Test the generated swiftinterface. |
| 21 | +// RUN: %target-swift-frontend -typecheck %t/FileA.swift %t/FileB.swift \ |
| 22 | +// RUN: -experimental-spi-only-imports \ |
| 23 | +// RUN: -swift-version 5 -enable-library-evolution -module-name Main -I %t \ |
| 24 | +// RUN: -emit-module-interface-path %t/Main.swiftinterface \ |
| 25 | +// RUN: -emit-private-module-interface-path %t/Main.private.swiftinterface |
| 26 | +// RUN: %target-swift-typecheck-module-from-interface(%t/Main.swiftinterface) -I %t |
| 27 | +// RUN: %target-swift-typecheck-module-from-interface(%t/Main.private.swiftinterface) \ |
| 28 | +// RUN: -module-name Main -I %t |
| 29 | +// RUN: %FileCheck -check-prefix=CHECK-PUBLIC %s < %t/Main.swiftinterface |
| 30 | +// RUN: %FileCheck -check-prefix=CHECK-PRIVATE %s < %t/Main.private.swiftinterface |
| 31 | + |
| 32 | +/// Test the case of a library-level=SPI where even the public swiftinterface |
| 33 | +/// also has SPI details. |
| 34 | +// RUN: %target-swift-frontend -typecheck %t/FileA.swift %t/FileB.swift \ |
| 35 | +// RUN: -experimental-spi-only-imports \ |
| 36 | +// RUN: -swift-version 5 -enable-library-evolution -module-name SPIMain -I %t \ |
| 37 | +// RUN: -emit-module-interface-path %t/SPIMain.swiftinterface \ |
| 38 | +// RUN: -emit-private-module-interface-path %t/SPIMain.private.swiftinterface \ |
| 39 | +// RUN: -library-level spi |
| 40 | +// RUN: %target-swift-typecheck-module-from-interface(%t/SPIMain.swiftinterface) -I %t |
| 41 | +// RUN: %target-swift-typecheck-module-from-interface(%t/SPIMain.private.swiftinterface) \ |
| 42 | +// RUN: -module-name SPIMain -I %t |
| 43 | +// RUN: %FileCheck -check-prefix=CHECK-PRIVATE %s < %t/SPIMain.swiftinterface |
| 44 | +// RUN: %FileCheck -check-prefix=CHECK-PRIVATE %s < %t/SPIMain.private.swiftinterface |
| 45 | + |
| 46 | +//--- Empty.swift |
| 47 | +//--- FileA.swift |
| 48 | + |
| 49 | +/// We don't need or want the flag in the swiftinterface |
| 50 | +// CHECK-PUBLIC-NOT: -experimental-spi-only-imports |
| 51 | +// CHECK-PRIVATE-NOT: -experimental-spi-only-imports |
| 52 | + |
| 53 | +@_spiOnly @_spi(SomeSPIGroup) import A_SPIOnlyImported |
| 54 | +// CHECK-PUBLIC-NOT: A_SPIOnlyImported |
| 55 | +// CHECK-PRIVATE: {{^}}/*@_spiOnly*/ @_spi(SomeSPIGroup) import A_SPIOnlyImported |
| 56 | + |
| 57 | +/// This is also imported as SPI only via FileB.swift |
| 58 | +@_spiOnly import ConstantSPIOnly |
| 59 | +// CHECK-PUBLIC-NOT: ConstantSPIOnly |
| 60 | +// CHECK-PRIVATE: {{^}}/*@_spiOnly*/ import ConstantSPIOnly |
| 61 | + |
| 62 | +/// This is also imported as SPI only via FileB.swift |
| 63 | +@_implementationOnly import InconsistentIOI |
| 64 | +// CHECK-PUBLIC-NOT: InconsistentIOI |
| 65 | +// CHECK-PRIVATE: {{^}}/*@_spiOnly*/ import InconsistentIOI |
| 66 | + |
| 67 | +/// This is also imported as SPI only via FileB.swift |
| 68 | +import InconsistentPublic |
| 69 | +// CHECK-PUBLIC: {{^}}import InconsistentPublic |
| 70 | +// CHECK-PRIVATE: {{^}}import InconsistentPublic |
| 71 | + |
| 72 | +@_implementationOnly import IOIImported |
| 73 | +// CHECK-PUBLIC-NOT: IOIImported |
| 74 | +// CHECK-PRIVATE-NOT: IOIImported |
| 75 | + |
| 76 | +@_spi(dummy) import SPIImported |
| 77 | +// CHECK-PUBLIC: {{^}}import SPIImported |
| 78 | +// CHECK-PRIVATE: @_spi{{.*}} import SPIImported |
| 79 | + |
| 80 | +@_spi(X) |
| 81 | +extension IOIPublicStruct { |
| 82 | + public func foo() {} |
| 83 | +} |
| 84 | +// CHECK-PUBLIC-NOT: A_SPIOnlyImported.IOIPublicStruct |
| 85 | +// CHECK-PRIVATE: @_spi{{.*}} extension A_SPIOnlyImported.IOIPublicStruct |
| 86 | + |
| 87 | +//--- FileB.swift |
| 88 | +@_spiOnly import ConstantSPIOnly |
| 89 | +@_spiOnly import InconsistentPublic |
| 90 | +@_spiOnly import InconsistentIOI |
0 commit comments