Skip to content

Commit 8e7fdb2

Browse files
committed
Sema: Test that we can't use SPI operators in inlinable code
1 parent 879f37c commit 8e7fdb2

File tree

1 file changed

+12
-0
lines changed

1 file changed

+12
-0
lines changed

test/SPI/local_spi_decls.swift

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -115,20 +115,32 @@ public func publicFuncWithDefaultValue(_ p: SPIClass = SPIClass()) {} // expecte
115115
@_spi(S)
116116
public func spiFuncWithDefaultValue(_ p: SPIClass = SPIClass()) {}
117117

118+
public struct PublicType {
119+
public init() { }
120+
}
121+
@_spi(S) public func -(_ s1: PublicType, _ s2: PublicType) -> PublicType { s1 }
122+
123+
public let o1 = PublicType()
124+
public let o2 = PublicType()
125+
118126
@inlinable
119127
public func inlinablePublic() {
120128
spiFunc() // expected-error {{global function 'spiFunc()' cannot be used in an '@inlinable' function because it is SPI}}
121129
let _ = SPIClass() // expected-error {{class 'SPIClass' cannot be used in an '@inlinable' function because it is SPI}}
122130
// expected-error@-1 {{initializer 'init()' cannot be used in an '@inlinable' function because it is SPI}}
131+
let _ = o1 - o2 // expected-error {{operator function '-' cannot be used in an '@inlinable' function because it is SPI}}
123132
}
124133

125134
@_spi(S)
126135
@inlinable
127136
public func inlinableSPI() {
128137
spiFunc()
129138
let _ = SPIClass()
139+
let _ = o1 - o2
130140
}
131141

132142
@_spi(S) func internalFunc() {} // expected-error {{internal global function cannot be declared '@_spi' because only public and open declarations can be '@_spi'}}
133143

134144
@_spi(S) package func packageFunc() {} // expected-error {{package global function cannot be declared '@_spi' because only public and open declarations can be '@_spi'}}
145+
146+
let _ = o1 - o2

0 commit comments

Comments
 (0)