Files
swift-mirror/test/SPI/export_spi_from_spi_module.swift
Allan Shortlidge 8e5988e5fc NFC: Increase test coverage for SPI enum elements.
These tests identified a gap in type checking the exportability of case statements. Unfortunately this gap is not simple to close, since exportability is usually checked during availability checking but availability checking isn't appropriate for case statements and there isn't existing infrastructure to check exportability independently.
2022-11-29 22:11:02 -08:00

45 lines
1008 B
Swift

/// Check that SPI declarations can be exported from an SPI module.
// RUN: %empty-directory(%t)
// RUN: %target-typecheck-verify-swift -I %t -verify-ignore-unknown -enable-library-evolution -swift-version 5 -library-level spi
@_spi(S) public func spiFunc() {}
@_spi(S) public class SPIClass {
public init() {}
}
@_spi(S) public class SPIStruct {
public init() {}
}
@_spi(S) public protocol SPIProtocol {}
public enum PublicEnum {
case publicCase
@_spi(S) case spiCase
}
public func useOfSPITypeOk(_ p0: SPIProtocol, p1: SPIClass) -> SPIClass { fatalError() }
@inlinable
public func inlinable() -> SPIClass {
spiFunc()
_ = SPIClass()
}
@inlinable
public func inlinable(_ e: PublicEnum) {
switch e {
case .publicCase: break
case .spiCase: break
@unknown default: break
}
if case .spiCase = e {}
_ = PublicEnum.spiCase
}
@frozen public struct FrozenStruct {
public var spiInFrozen = SPIStruct()
var spiTypeInFrozen = SPIStruct()
private var spiTypeInFrozen1: SPIClass
}