|
| 1 | +// RUN: %empty-directory(%t) |
| 2 | +// RUN: split-file %s %t |
| 3 | + |
| 4 | +// RUN: %target-swift-frontend -emit-module %t/Lib.swift \ |
| 5 | +// RUN: -module-name Lib -swift-version 5 -I %t \ |
| 6 | +// RUN: -enable-library-evolution \ |
| 7 | +// RUN: -emit-module-path %t/Lib.swiftmodule \ |
| 8 | +// RUN: -emit-module-interface-path %t/Lib.swiftinterface \ |
| 9 | +// RUN: -emit-private-module-interface-path %t/Lib.private.swiftinterface |
| 10 | + |
| 11 | +// RUN: %target-swift-frontend -typecheck -verify %t/ClientA.swift -I %t |
| 12 | +// RUN: %target-swift-frontend -typecheck -verify %t/ClientB.swift -I %t |
| 13 | +// RUN: %target-swift-frontend -typecheck -verify %t/ClientC.swift -I %t |
| 14 | + |
| 15 | +// RUN: rm %t/Lib.swiftmodule |
| 16 | +// RUN: %target-swift-frontend -typecheck -verify %t/ClientA.swift -I %t |
| 17 | +// RUN: %target-swift-frontend -typecheck -verify %t/ClientB.swift -I %t |
| 18 | +// RUN: %target-swift-frontend -typecheck -verify %t/ClientC.swift -I %t |
| 19 | + |
| 20 | +// RUN: %target-swift-frontend -emit-module %t/ClientA.swift \ |
| 21 | +// RUN: -module-name ClientA -swift-version 5 -I %t \ |
| 22 | +// RUN: -enable-library-evolution \ |
| 23 | +// RUN: -emit-module-interface-path %t/ClientA.swiftinterface \ |
| 24 | +// RUN: -emit-private-module-interface-path %t/ClientA.private.swiftinterface |
| 25 | +// RUN: %FileCheck %s --check-prefix CHECK-A < %t/ClientA.private.swiftinterface |
| 26 | +// CHECK-A-NOT: @_spi(_) import Lib |
| 27 | +// CHECK-A: import Lib |
| 28 | +// CHECK-A: @_spi(_) public func useImplicit() -> Lib._Klass |
| 29 | + |
| 30 | +// RUN: %target-swift-frontend -emit-module %t/ClientB.swift \ |
| 31 | +// RUN: -module-name ClientB -swift-version 5 -I %t \ |
| 32 | +// RUN: -enable-library-evolution \ |
| 33 | +// RUN: -emit-module-interface-path %t/ClientB.swiftinterface \ |
| 34 | +// RUN: -emit-private-module-interface-path %t/ClientB.private.swiftinterface |
| 35 | +// RUN: %FileCheck %s --check-prefix CHECK-B < %t/ClientB.private.swiftinterface |
| 36 | +// CHECK-B-NOT: @_spi(_) @_spi(core) import Lib |
| 37 | +// CHECK-B-NOT: @_spi(core) @_spi(_) import Lib |
| 38 | +// CHECK-B: @_spi(core) import Lib |
| 39 | +// CHECK-B: @_spi(_) public func useImplicit() -> Lib._Klass |
| 40 | +// CHECK-B: @_spi(core) public func useSPICore() -> Lib.CoreStruct |
| 41 | + |
| 42 | +// RUN: %target-swift-frontend -emit-module %t/ClientZ.swift \ |
| 43 | +// RUN: -module-name ClientZ -swift-version 5 -I %t \ |
| 44 | +// RUN: -enable-library-evolution \ |
| 45 | +// RUN: -emit-module-interface-path %t/ClientZ.swiftinterface \ |
| 46 | +// RUN: -emit-private-module-interface-path %t/ClientZ.private.swiftinterface |
| 47 | +// RUN: %FileCheck %s --check-prefix CHECK-Z < %t/ClientZ.private.swiftinterface |
| 48 | +// CHECK-Z: @_spi(_) import Lib |
| 49 | +// CHECK-Z: @_spi(_) public func useImplicit() -> Lib._Klass |
| 50 | + |
| 51 | + |
| 52 | +//--- Lib.swift |
| 53 | + |
| 54 | +@_spi(core) |
| 55 | +public struct CoreStruct { |
| 56 | + public init() {} |
| 57 | +} |
| 58 | + |
| 59 | +@_spi(_) |
| 60 | +public class _Klass { |
| 61 | + public init() {} |
| 62 | +} |
| 63 | + |
| 64 | +public protocol APIProtocol { |
| 65 | +} |
| 66 | + |
| 67 | + |
| 68 | +//--- ClientA.swift |
| 69 | + |
| 70 | +import Lib |
| 71 | + |
| 72 | +@_spi(_) |
| 73 | +public func useImplicit() -> _Klass { return _Klass() } |
| 74 | + |
| 75 | +public func useMain() -> APIProtocol? { return nil } |
| 76 | + |
| 77 | + |
| 78 | +//--- ClientB.swift |
| 79 | + |
| 80 | +@_spi(core) import Lib |
| 81 | + |
| 82 | +@_spi(_) |
| 83 | +public func useImplicit() -> _Klass { return _Klass() } |
| 84 | + |
| 85 | +@_spi(core) |
| 86 | +public func useSPICore() -> CoreStruct { return CoreStruct() } |
| 87 | + |
| 88 | +public func useMain() -> APIProtocol? { return nil } |
| 89 | + |
| 90 | + |
| 91 | +//--- ClientC.swift |
| 92 | + |
| 93 | +import Lib |
| 94 | + |
| 95 | +public func useImplicit() -> _Klass { return _Klass() } // expected-error{{cannot use class '_Klass' here; it is an SPI imported from 'Lib'}} |
| 96 | + |
| 97 | +@_spi(core) |
| 98 | +public func useSPICore() -> CoreStruct { return CoreStruct() } // expected-error{{cannot find type 'CoreStruct' in scope}} |
| 99 | + |
| 100 | +public func useMain() -> APIProtocol? { return nil } |
| 101 | + |
| 102 | + |
| 103 | +//--- ClientZ.swift |
| 104 | + |
| 105 | +@_spi(_) import Lib |
| 106 | + |
| 107 | +@_spi(_) |
| 108 | +public func useImplicit() -> _Klass { return _Klass() } |
| 109 | + |
| 110 | +public func useMain() -> APIProtocol? { return nil } |
0 commit comments