|
20 | 20 | // RUN: %target-swift-frontend -emit-module %t/UnusedPackageImport.swift -o %t -I %t
|
21 | 21 | // RUN: %target-swift-frontend -emit-module %t/ImportNotUseFromAPI.swift -o %t -I %t
|
22 | 22 | // RUN: %target-swift-frontend -emit-module %t/ImportUsedInPackage.swift -o %t -I %t
|
| 23 | +// RUN: %target-swift-frontend -emit-module %t/ExportedUnused.swift -o %t -I %t |
| 24 | +// RUN: %target-swift-frontend -emit-module %t/SPIOnlyUsedInSPI.swift -o %t -I %t |
23 | 25 |
|
24 | 26 | /// Check diagnostics.
|
25 | 27 | // RUN: %target-swift-frontend -typecheck %t/Client.swift -I %t \
|
26 |
| -// RUN: -package-name pkg -Rmodule-api-import -swift-version 6 -verify |
| 28 | +// RUN: -package-name pkg -Rmodule-api-import -swift-version 6 -verify \ |
| 29 | +// RUN: -experimental-spi-only-imports |
27 | 30 | // RUN: %target-swift-frontend -typecheck %t/ClientOfClangModules.swift -I %t \
|
28 | 31 | // RUN: -package-name pkg -Rmodule-api-import -swift-version 6 -verify
|
29 | 32 | // RUN: %target-swift-frontend -typecheck %t/Client_Swift5.swift -I %t \
|
@@ -102,6 +105,11 @@ public func notAnAPIFunc() -> NotAnAPIType { return NotAnAPIType() }
|
102 | 105 | public struct PackageType {}
|
103 | 106 | public func packageFunc() -> PackageType { return PackageType() }
|
104 | 107 |
|
| 108 | +//--- ExportedUnused.swift |
| 109 | + |
| 110 | +//--- SPIOnlyUsedInSPI.swift |
| 111 | +public struct ToUseFromSPI {} |
| 112 | + |
105 | 113 | //--- Client_Swift5.swift
|
106 | 114 | /// No diagnostics should be raised on the implicit access level.
|
107 | 115 | import UnusedImport // expected-error {{ambiguous implicit access level for import of 'UnusedImport'; it is imported as 'public' elsewhere}}
|
@@ -133,6 +141,9 @@ package import UnusedPackageImport // expected-warning {{package import of 'Unus
|
133 | 141 | public import ImportNotUseFromAPI // expected-warning {{public import of 'ImportNotUseFromAPI' was not used in public declarations or inlinable code}} {{1-8=}}
|
134 | 142 | public import ImportUsedInPackage // expected-warning {{public import of 'ImportUsedInPackage' was not used in public declarations or inlinable code}} {{1-7=package}}
|
135 | 143 |
|
| 144 | +@_exported public import ExportedUnused |
| 145 | +@_spiOnly public import SPIOnlyUsedInSPI |
| 146 | + |
136 | 147 | public func useInSignature(_ a: TypeUsedInSignature) {} // expected-remark {{struct 'TypeUsedInSignature' is imported via 'DepUsedInSignature'}}
|
137 | 148 | public func exportedTypeUseInSignature(_ a: ExportedType) {} // expected-remark {{struct 'ExportedType' is imported via 'Exporter', which reexports definition from 'Exportee'}}
|
138 | 149 |
|
@@ -214,6 +225,9 @@ func implicitlyInternalFunc(a: NotAnAPIType = notAnAPIFunc()) {}
|
214 | 225 | // For package decls we only remark on types used in signatures, not for inlinable code.
|
215 | 226 | package func packageFunc(a: PackageType = packageFunc()) {} // expected-remark {{struct 'PackageType' is imported via 'ImportUsedInPackage'}}
|
216 | 227 |
|
| 228 | +@_spi(X) |
| 229 | +public func spiFunc(a: ToUseFromSPI) {} // expected-remark {{struct 'ToUseFromSPI' is imported via 'SPIOnlyUsedInSPI'}} |
| 230 | + |
217 | 231 | /// Tests for imports of clang modules.
|
218 | 232 | //--- module.modulemap
|
219 | 233 | module ClangSimpleUnused {
|
|
0 commit comments