|
| 1 | +// RUN: %empty-directory(%t) |
| 2 | +// RUN: split-file %s %t |
| 3 | + |
| 4 | +// RUN: %target-swift-frontend -emit-module %t/Lib.swift -I %t \ |
| 5 | +// RUN: -module-name Lib -emit-module-path %t/Lib.swiftmodule \ |
| 6 | +// RUN: -swift-version 5 |
| 7 | + |
| 8 | +/// Use of IOI types in SPI signatures is an error with -experimental-spi-only-imports |
| 9 | +// RUN: %target-swift-frontend -emit-module %t/ClientSPIOnlyMode.swift -I %t \ |
| 10 | +// RUN: -swift-version 5 -verify \ |
| 11 | +// RUN: -experimental-spi-only-imports |
| 12 | + |
| 13 | +/// Use of IOI types in SPI signatures is a warning without -experimental-spi-only-imports |
| 14 | +// RUN: %target-swift-frontend -emit-module %t/ClientDefaultMode.swift -I %t \ |
| 15 | +// RUN: -swift-version 5 -verify |
| 16 | + |
| 17 | +/// This is a warning in swiftinterfaces |
| 18 | +// R UN: %target-swift-typecheck-module-from-interface(%t/Client.private.swiftinterface) \ |
| 19 | +// R UN: -I %t -module-name Client |
| 20 | + |
| 21 | +//--- Lib.swift |
| 22 | + |
| 23 | +public struct IOIStruct { |
| 24 | + public init() {} |
| 25 | +} |
| 26 | + |
| 27 | +//--- ClientSPIOnlyMode.swift |
| 28 | + |
| 29 | +@_implementationOnly import Lib |
| 30 | + |
| 31 | +@_spi(X) public func spiClient(s: IOIStruct) -> IOIStruct { // expected-error 2 {{cannot use struct 'IOIStruct' here; 'Lib' has been imported as implementation-only}} |
| 32 | + return IOIStruct() |
| 33 | +} |
| 34 | + |
| 35 | +@_spi(X) @inlinable public func inlinableClient(s: IOIStruct) -> IOIStruct { // expected-error 2 {{struct 'IOIStruct' cannot be used in an '@inlinable' function because 'Lib' was imported implementation-only}} |
| 36 | + return IOIStruct() // expected-error {{struct 'IOIStruct' cannot be used in an '@inlinable' function because 'Lib' was imported implementation-only}} |
| 37 | + // expected-error @-1 {{initializer 'init()' cannot be used in an '@inlinable' function because 'Lib' was imported implementation-only}} |
| 38 | +} |
| 39 | + |
| 40 | +//--- ClientDefaultMode.swift |
| 41 | + |
| 42 | +@_implementationOnly import Lib |
| 43 | + |
| 44 | +@_spi(X) public func spiClient(s: IOIStruct) -> IOIStruct { // expected-warning 2 {{cannot use struct 'IOIStruct' here; 'Lib' has been imported as implementation-only}} |
| 45 | + return IOIStruct() |
| 46 | +} |
| 47 | + |
| 48 | +@_spi(X) @inlinable public func inlinableClient(s: IOIStruct) -> IOIStruct { // expected-error 2 {{struct 'IOIStruct' cannot be used in an '@inlinable' function because 'Lib' was imported implementation-only}} |
| 49 | + return IOIStruct() // expected-error {{struct 'IOIStruct' cannot be used in an '@inlinable' function because 'Lib' was imported implementation-only}} |
| 50 | + // expected-error @-1 {{initializer 'init()' cannot be used in an '@inlinable' function because 'Lib' was imported implementation-only}} |
| 51 | +} |
| 52 | + |
| 53 | +//--- Client.private.swiftinterface |
| 54 | + |
| 55 | +// swift-interface-format-version: 1.0 |
| 56 | +// swift-compiler-version: Swift version 5.8-dev effective-4.1.50 |
| 57 | +// swift-module-flags: -swift-version 4 -module-name Client |
| 58 | +@_implementationOnly import Lib |
| 59 | + |
| 60 | +@_spi(X) public func spiClient() -> IOIStruct { fatalError() } |
0 commit comments