Skip to content

Commit 495035d

Browse files
committed
Sema: Add tests for embedded exportability checking with accessors
1 parent 0136e19 commit 495035d

File tree

2 files changed

+42
-0
lines changed

2 files changed

+42
-0
lines changed

test/Sema/implementation-only-import-embedded.swift

Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -150,6 +150,39 @@ internal func explicitNonInliableInternal(arg: StructFromDirect = StructFromDire
150150
explicitNonInliable()
151151
}
152152

153+
struct Accessors {
154+
public var var1: Int {
155+
get {
156+
globalFunctionFromDirect() // expected-error {{global function 'globalFunctionFromDirect()' cannot be used in an embedded function not marked '@_neverEmitIntoClient' because 'directs' was imported implementation-only}}
157+
return 0
158+
}
159+
}
160+
161+
@_alwaysEmitIntoClient
162+
public var var2: Int {
163+
get {
164+
globalFunctionFromDirect() // expected-error {{global function 'globalFunctionFromDirect()' cannot be used in an embedded function not marked '@_neverEmitIntoClient' because 'directs' was imported implementation-only}}
165+
return 0
166+
}
167+
}
168+
169+
@_neverEmitIntoClient
170+
public var var3: Int {
171+
get {
172+
globalFunctionFromDirect()
173+
return 0
174+
}
175+
}
176+
177+
public var var4: Int {
178+
@_neverEmitIntoClient
179+
get {
180+
globalFunctionFromDirect()
181+
return 0
182+
}
183+
}
184+
}
185+
153186
public func legalAccessToIndirect(arg: StructFromIndirect = StructFromIndirect()) {
154187
_ = StructFromIndirect()
155188

test/embedded/implementation-only-import-build.swift

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -57,3 +57,12 @@ public func legalAccessToIndirect() {
5757
}
5858
nested()
5959
}
60+
61+
extension Array {
62+
@_alwaysEmitIntoClient
63+
public var myMutableSpan: Int {
64+
get {
65+
return 0
66+
}
67+
}
68+
}

0 commit comments

Comments
 (0)