File tree Expand file tree Collapse file tree 5 files changed +73
-1
lines changed Expand file tree Collapse file tree 5 files changed +73
-1
lines changed Original file line number Diff line number Diff line change @@ -89,3 +89,8 @@ public struct PublicStruct {
89
89
@_spi ( HelperSPI) public struct IntLike : ExpressibleByIntegerLiteral , Equatable {
90
90
@_spi ( HelperSPI) public init ( integerLiteral: Int ) { }
91
91
}
92
+
93
+ public enum PublicEnum {
94
+ case publicCase
95
+ @_spi ( HelperSPI) case spiCase
96
+ }
Original file line number Diff line number Diff line change 11
11
public init ( ) { }
12
12
}
13
13
@_spi ( S) public protocol SPIProtocol { }
14
+ public enum PublicEnum {
15
+ case publicCase
16
+ @_spi ( S) case spiCase
17
+ }
14
18
15
19
public func useOfSPITypeOk( _ p0: SPIProtocol , p1: SPIClass ) -> SPIClass { fatalError ( ) }
16
20
17
21
@inlinable
18
- func inlinable( ) -> SPIClass {
22
+ public func inlinable( ) -> SPIClass {
19
23
spiFunc ( )
20
24
_ = SPIClass ( )
21
25
}
22
26
27
+ @inlinable
28
+ public func inlinable( _ e: PublicEnum ) {
29
+ switch e {
30
+ case . publicCase: break
31
+ case . spiCase: break
32
+ @unknown default : break
33
+ }
34
+
35
+ if case . spiCase = e { }
36
+
37
+ _ = PublicEnum . spiCase
38
+ }
39
+
23
40
@frozen public struct FrozenStruct {
24
41
public var spiInFrozen = SPIStruct ( )
25
42
var spiTypeInFrozen = SPIStruct ( )
Original file line number Diff line number Diff line change @@ -27,6 +27,7 @@ internalFunc() // expected-error {{cannot find 'internalFunc' in scope}}
27
27
let c = SPIClass ( ) // expected-error {{cannot find 'SPIClass' in scope}}
28
28
let s = SPIStruct ( ) // expected-error {{cannot find 'SPIStruct' in scope}}
29
29
SPIEnum ( ) . spiMethod ( ) // expected-error {{cannot find 'SPIEnum' in scope}}
30
+ _ = PublicEnum . spiCase // expected-error {{'spiCase' is inaccessible due to '@_spi' protection level}}
30
31
31
32
var ps = PublicStruct ( )
32
33
let _ = PublicStruct ( alt_init: 1 ) // expected-error {{argument passed to call that takes no arguments}}
Original file line number Diff line number Diff line change @@ -40,6 +40,7 @@ print(s.spiVar)
40
40
41
41
SPIEnum ( ) . spiMethod ( )
42
42
SPIEnum . A. spiMethod ( )
43
+ _ = PublicEnum . spiCase
43
44
44
45
var ps = PublicStruct ( )
45
46
let _ = PublicStruct ( alt_init: 1 )
Original file line number Diff line number Diff line change
1
+ // RUN: %target-typecheck-verify-swift -swift-version 5
2
+ // RUN: %target-typecheck-verify-swift -swift-version 5 -enable-library-evolution
3
+
4
+ public enum PublicEnum {
5
+ case publicCase
6
+ @_spi ( S) case spiCase
7
+ }
8
+
9
+ @inlinable public func publicInlinableFunc( _ e: PublicEnum ) {
10
+ switch e {
11
+ case . publicCase: break
12
+ case . spiCase: break // FIXME: this should be diagnosed with "cannot use enum case 'spiCase' here; it is SPI"
13
+ @unknown default : break
14
+ }
15
+
16
+ if case . spiCase = e { } // FIXME: this should be diagnosed with "cannot use enum case 'spiCase' here; it is SPI"
17
+
18
+ _ = PublicEnum . spiCase // expected-error {{enum case 'spiCase' cannot be used in an '@inlinable' function because it is SPI}}
19
+ }
20
+
21
+ @_spi ( S)
22
+ @inlinable public func spiInlinableFunc( _ e: PublicEnum ) {
23
+ switch e {
24
+ case . publicCase: break
25
+ case . spiCase: break
26
+ @unknown default : break
27
+ }
28
+
29
+ if case . spiCase = e { }
30
+
31
+ _ = PublicEnum . spiCase
32
+ }
33
+
34
+ public struct PublicStruct { }
35
+ @_spi ( S) public struct SPIStruct { } // expected-note {{type declared here}}
36
+
37
+ public enum PublicEnumWithPayloads {
38
+ case publicCasePublicPayload( _ s: PublicStruct )
39
+ case publicCaseSPIPayload( _ s: SPIStruct ) // expected-error {{cannot use struct 'SPIStruct' here; it is SPI}}
40
+ @_spi ( S) case spiCasePublicPayload( _ s: PublicStruct )
41
+ @_spi ( S) case spiCaseSPIPayload( _ s: SPIStruct )
42
+ }
43
+
44
+ @_spi ( S)
45
+ public enum SPIEnumWithPayloads {
46
+ case publicPayloadCase( _ s: PublicStruct )
47
+ case spiPayloadCase( _ s: SPIStruct )
48
+ }
You can’t perform that action at this time.
0 commit comments