|
| 1 | +// RUN: %empty-directory(%t) |
| 2 | +// RUN: %target-typecheck-verify-swift \ |
| 3 | +// RUN: -enable-library-evolution -swift-version 5 \ |
| 4 | +// RUN: -library-level=api -require-explicit-availability=ignore |
| 5 | + |
| 6 | +// REQUIRES: OS=macosx |
| 7 | + |
| 8 | +@_spi_available(macOS, introduced: 12.0) @available(iOS 12.0, *) |
| 9 | +public struct SPIAvailableType { // expected-note {{struct declared here}} |
| 10 | + public init() {} |
| 11 | +} |
| 12 | + |
| 13 | +@_spi(S) |
| 14 | +public struct NormalSPIType { |
| 15 | + public init() {} |
| 16 | +} |
| 17 | + |
| 18 | +// SPI available in SPI available should be accepted. |
| 19 | + |
| 20 | +@_spi_available(macOS, introduced: 12.0) @available(iOS 12.0, *) |
| 21 | +public struct OtherSPIAvailableType { |
| 22 | + public func foo(s: SPIAvailableType) {} |
| 23 | +} |
| 24 | + |
| 25 | +extension OtherSPIAvailableType { |
| 26 | + public func bar(s: SPIAvailableType) {} // expected-error {{cannot use struct 'SPIAvailableType' here; it is SPI}} // FIXME We should allow this. |
| 27 | +} |
| 28 | + |
| 29 | +// Normal SPI in normal SPI should be accepted. |
| 30 | + |
| 31 | +@_spi(S) |
| 32 | +public struct OtherNormalSPIType { |
| 33 | + public func foo(s: SPIAvailableType) {} |
| 34 | +} |
| 35 | + |
| 36 | +extension OtherNormalSPIType { |
| 37 | + public func bar2(s: SPIAvailableType) {} |
| 38 | +} |
| 39 | + |
| 40 | +// Normal SPI in SPI available should be rejected. |
| 41 | + |
| 42 | +@_spi_available(macOS, introduced: 12.0) @available(iOS 12.0, *) |
| 43 | +public func SPIAvailableToSPI(s: NormalSPIType) {} // FIXME This should be an error |
| 44 | + |
| 45 | +@inlinable |
| 46 | +@_spi_available(macOS, introduced: 12.0) @available(iOS 12.0, *) |
| 47 | +public func inlinableSPIAvailable() { |
| 48 | + let _: NormalSPIType = NormalSPIType() // FIXME There should be many errors here |
| 49 | +} |
| 50 | + |
| 51 | +// SPI available in normal SPI is currently accepted. |
| 52 | + |
| 53 | +@_spi(S) |
| 54 | +public func SPIToSPIAvailable(s: NormalSPIType) {} |
| 55 | + |
| 56 | +@inlinable |
| 57 | +@_spi(S) |
| 58 | +public func inlinableSPI() { |
| 59 | + let _: SPIAvailableType = SPIAvailableType() |
| 60 | +} |
0 commit comments