Skip to content

Commit a9bd856

Browse files
authored
Merge pull request #80166 from atrick/test-interface
Add tests for lifetime inference on .swiftinterface
2 parents 9672494 + 4d4e3d9 commit a9bd856

File tree

2 files changed

+364
-0
lines changed

2 files changed

+364
-0
lines changed
Lines changed: 352 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,352 @@
1+
// swift-interface-format-version: 1.0
2+
// swift-compiler-version: Swift version 6.2-dev effective-5.10 (LLVM 09f3cd831902283, Swift 889522485775a5d)
3+
// swift-module-flags: -module-name lifetime_depend_infer -enable-experimental-feature LifetimeDependence -swift-version 5 -enable-library-evolution
4+
// swift-module-flags-ignorable: -formal-cxx-interoperability-mode=off -interface-compiler-version 6.2
5+
import Swift
6+
import _Concurrency
7+
import _StringProcessing
8+
import _SwiftConcurrencyShims
9+
@_hasMissingDesignatedInitializers public class C {}
10+
public struct NE : ~Swift.Escapable {
11+
}
12+
public struct NEImmortal : ~Swift.Escapable {
13+
#if $LifetimeDependence
14+
@lifetime(immortal)
15+
public init()
16+
#endif
17+
}
18+
public struct NonEscapableSelf : ~Swift.Escapable {
19+
#if $LifetimeDependence
20+
public func methodNoParam() -> lifetime_depend_infer.NonEscapableSelf
21+
#endif
22+
#if $LifetimeDependence
23+
@lifetime(self)
24+
public func methodNoParamLifetime() -> lifetime_depend_infer.NonEscapableSelf
25+
#endif
26+
#if $LifetimeDependence
27+
@lifetime(copy self)
28+
public func methodNoParamCopy() -> lifetime_depend_infer.NonEscapableSelf
29+
#endif
30+
#if $LifetimeDependence
31+
@lifetime(borrow self)
32+
public func methodNoParamBorrow() -> lifetime_depend_infer.NonEscapableSelf
33+
#endif
34+
#if $LifetimeDependence
35+
@lifetime(self)
36+
public mutating func mutatingMethodNoParamLifetime() -> lifetime_depend_infer.NonEscapableSelf
37+
#endif
38+
#if $LifetimeDependence
39+
@lifetime(copy self)
40+
public mutating func mutatingMethodNoParamCopy() -> lifetime_depend_infer.NonEscapableSelf
41+
#endif
42+
#if $LifetimeDependence
43+
@lifetime(borrow self)
44+
public mutating func mutatingMethodNoParamBorrow() -> lifetime_depend_infer.NonEscapableSelf
45+
#endif
46+
#if $LifetimeDependence
47+
public func methodOneParam(_: Swift.Int) -> lifetime_depend_infer.NonEscapableSelf
48+
#endif
49+
#if $LifetimeDependence
50+
@lifetime(self)
51+
public func methodOneParamLifetime(_: Swift.Int) -> lifetime_depend_infer.NonEscapableSelf
52+
#endif
53+
#if $LifetimeDependence
54+
@lifetime(copy self)
55+
public func methodOneParamCopy(_: Swift.Int) -> lifetime_depend_infer.NonEscapableSelf
56+
#endif
57+
#if $LifetimeDependence
58+
@lifetime(borrow self)
59+
public func methodOneParamBorrow(_: Swift.Int) -> lifetime_depend_infer.NonEscapableSelf
60+
#endif
61+
#if $LifetimeDependence
62+
@lifetime(self)
63+
public mutating func mutatingMethodOneParamLifetime(_: Swift.Int) -> lifetime_depend_infer.NonEscapableSelf
64+
#endif
65+
#if $LifetimeDependence
66+
@lifetime(copy self)
67+
public mutating func mutatingMethodOneParamCopy(_: Swift.Int) -> lifetime_depend_infer.NonEscapableSelf
68+
#endif
69+
#if $LifetimeDependence
70+
@lifetime(borrow self)
71+
public mutating func mutatingMethodOneParamBorrow(_: Swift.Int) -> lifetime_depend_infer.NonEscapableSelf
72+
#endif
73+
}
74+
public struct EscapableTrivialSelf {
75+
#if compiler(>=5.3) && $NonescapableTypes && $LifetimeDependence
76+
@lifetime(self)
77+
public func methodNoParamLifetime() -> lifetime_depend_infer.NEImmortal
78+
#endif
79+
#if compiler(>=5.3) && $NonescapableTypes && $LifetimeDependence
80+
@lifetime(borrow self)
81+
public func methodNoParamBorrow() -> lifetime_depend_infer.NEImmortal
82+
#endif
83+
#if compiler(>=5.3) && $NonescapableTypes && $LifetimeDependence
84+
@lifetime(self)
85+
public mutating func mutatingMethodNoParamLifetime() -> lifetime_depend_infer.NEImmortal
86+
#endif
87+
#if compiler(>=5.3) && $NonescapableTypes && $LifetimeDependence
88+
@lifetime(borrow self)
89+
public mutating func mutatingMethodNoParamBorrow() -> lifetime_depend_infer.NEImmortal
90+
#endif
91+
#if compiler(>=5.3) && $NonescapableTypes && $LifetimeDependence
92+
@lifetime(self)
93+
public func methodOneParamLifetime(_: Swift.Int) -> lifetime_depend_infer.NEImmortal
94+
#endif
95+
#if compiler(>=5.3) && $NonescapableTypes && $LifetimeDependence
96+
@lifetime(borrow self)
97+
public func methodOneParamBorrow(_: Swift.Int) -> lifetime_depend_infer.NEImmortal
98+
#endif
99+
#if compiler(>=5.3) && $NonescapableTypes && $LifetimeDependence
100+
@lifetime(self)
101+
public mutating func mutatingMethodOneParamLifetime(_: Swift.Int) -> lifetime_depend_infer.NEImmortal
102+
#endif
103+
#if compiler(>=5.3) && $NonescapableTypes && $LifetimeDependence
104+
@lifetime(borrow self)
105+
public mutating func mutatingMethodOneParamBorrow(_: Swift.Int) -> lifetime_depend_infer.NEImmortal
106+
#endif
107+
}
108+
public struct EscapableNonTrivialSelf {
109+
public init(c: lifetime_depend_infer.C)
110+
#if compiler(>=5.3) && $NonescapableTypes && $LifetimeDependence
111+
public func methodNoParam() -> lifetime_depend_infer.NEImmortal
112+
#endif
113+
#if compiler(>=5.3) && $NonescapableTypes && $LifetimeDependence
114+
@lifetime(self)
115+
public func methodNoParamLifetime() -> lifetime_depend_infer.NEImmortal
116+
#endif
117+
#if compiler(>=5.3) && $NonescapableTypes && $LifetimeDependence
118+
@lifetime(borrow self)
119+
public func methodNoParamBorrow() -> lifetime_depend_infer.NEImmortal
120+
#endif
121+
#if compiler(>=5.3) && $NonescapableTypes && $LifetimeDependence
122+
public func mutatingMethodNoParam() -> lifetime_depend_infer.NEImmortal
123+
#endif
124+
#if compiler(>=5.3) && $NonescapableTypes && $LifetimeDependence
125+
@lifetime(self)
126+
public mutating func mutatingMethodNoParamLifetime() -> lifetime_depend_infer.NEImmortal
127+
#endif
128+
#if compiler(>=5.3) && $NonescapableTypes && $LifetimeDependence
129+
@lifetime(borrow self)
130+
public mutating func mutatingMethodNoParamBorrow() -> lifetime_depend_infer.NEImmortal
131+
#endif
132+
#if compiler(>=5.3) && $NonescapableTypes && $LifetimeDependence
133+
public func methodOneParam(_: Swift.Int) -> lifetime_depend_infer.NEImmortal
134+
#endif
135+
#if compiler(>=5.3) && $NonescapableTypes && $LifetimeDependence
136+
@lifetime(self)
137+
public func methodOneParamLifetime(_: Swift.Int) -> lifetime_depend_infer.NEImmortal
138+
#endif
139+
#if compiler(>=5.3) && $NonescapableTypes && $LifetimeDependence
140+
@lifetime(borrow self)
141+
public func methodOneParamBorrow(_: Swift.Int) -> lifetime_depend_infer.NEImmortal
142+
#endif
143+
#if compiler(>=5.3) && $NonescapableTypes && $LifetimeDependence
144+
public mutating func mutatingMethodOneParam(_: Swift.Int) -> lifetime_depend_infer.NEImmortal
145+
#endif
146+
#if compiler(>=5.3) && $NonescapableTypes && $LifetimeDependence
147+
@lifetime(self)
148+
public mutating func mutatingMethodOneParamLifetime(_: Swift.Int) -> lifetime_depend_infer.NEImmortal
149+
#endif
150+
#if compiler(>=5.3) && $NonescapableTypes && $LifetimeDependence
151+
@lifetime(borrow self)
152+
public mutating func mutatingMethodOneParamBorrow(_: Swift.Int) -> lifetime_depend_infer.NEImmortal
153+
#endif
154+
}
155+
public struct NonescapableInitializers : ~Swift.Escapable {
156+
public var c: lifetime_depend_infer.C
157+
#if $LifetimeDependence
158+
public init(ne: lifetime_depend_infer.NE)
159+
#endif
160+
}
161+
public struct NonescapableConsumingInitializers : ~Swift.Escapable {
162+
public var c: lifetime_depend_infer.C
163+
#if $LifetimeDependence
164+
public init(ne: consuming lifetime_depend_infer.NE)
165+
#endif
166+
}
167+
public struct NonescapableBorrowingInitializers : ~Swift.Escapable {
168+
public var c: lifetime_depend_infer.C
169+
#if $LifetimeDependence
170+
public init(c: borrowing lifetime_depend_infer.C)
171+
#endif
172+
#if $LifetimeDependence
173+
public init(c: borrowing lifetime_depend_infer.C, _: Swift.Int)
174+
#endif
175+
#if $LifetimeDependence
176+
public init(ne: borrowing lifetime_depend_infer.NE)
177+
#endif
178+
}
179+
public struct NonescapableInoutInitializers : ~Swift.Escapable {
180+
public var c: lifetime_depend_infer.C
181+
#if $LifetimeDependence
182+
public init(c: inout lifetime_depend_infer.C)
183+
#endif
184+
}
185+
#if $LifetimeDependence
186+
@lifetime(immortal)
187+
public func noParamImmortal() -> lifetime_depend_infer.NEImmortal
188+
#endif
189+
#if $LifetimeDependence
190+
@lifetime(c)
191+
public func oneParamLifetime(c: lifetime_depend_infer.C) -> lifetime_depend_infer.NEImmortal
192+
#endif
193+
#if $LifetimeDependence
194+
public func oneParamBorrow(c: borrowing lifetime_depend_infer.C) -> lifetime_depend_infer.NEImmortal
195+
#endif
196+
#if $LifetimeDependence
197+
@lifetime(c)
198+
public func oneParamBorrowLifetime(c: borrowing lifetime_depend_infer.C) -> lifetime_depend_infer.NEImmortal
199+
#endif
200+
#if $LifetimeDependence
201+
public func oneParamInout(c: inout lifetime_depend_infer.C) -> lifetime_depend_infer.NEImmortal
202+
#endif
203+
#if $LifetimeDependence
204+
@lifetime(c)
205+
public func oneParamInoutLifetime(c: inout lifetime_depend_infer.C) -> lifetime_depend_infer.NEImmortal
206+
#endif
207+
#if $LifetimeDependence
208+
@lifetime(c)
209+
public func twoParamsLifetime(c: lifetime_depend_infer.C, _: Swift.Int) -> lifetime_depend_infer.NEImmortal
210+
#endif
211+
#if $LifetimeDependence
212+
public func twoParamsBorrow(c: borrowing lifetime_depend_infer.C, _: Swift.Int) -> lifetime_depend_infer.NEImmortal
213+
#endif
214+
#if $LifetimeDependence
215+
public func neParam(ne: lifetime_depend_infer.NE) -> lifetime_depend_infer.NE
216+
#endif
217+
#if $LifetimeDependence
218+
@lifetime(ne)
219+
public func neParamLifetime(ne: lifetime_depend_infer.NE) -> lifetime_depend_infer.NE
220+
#endif
221+
#if $LifetimeDependence
222+
public func neParamBorrow(ne: borrowing lifetime_depend_infer.NE) -> lifetime_depend_infer.NE
223+
#endif
224+
#if $LifetimeDependence
225+
@lifetime(ne)
226+
public func neParamBorrowLifetime(ne: borrowing lifetime_depend_infer.NE) -> lifetime_depend_infer.NE
227+
#endif
228+
#if $LifetimeDependence
229+
public func neParamConsume(ne: consuming lifetime_depend_infer.NE) -> lifetime_depend_infer.NE
230+
#endif
231+
#if $LifetimeDependence
232+
@lifetime(ne)
233+
public func neParamConsumeLifetime(ne: consuming lifetime_depend_infer.NE) -> lifetime_depend_infer.NE
234+
#endif
235+
#if $LifetimeDependence
236+
public func neTwoParam(ne: lifetime_depend_infer.NE, _: Swift.Int) -> lifetime_depend_infer.NE
237+
#endif
238+
public struct Accessors {
239+
#if $LifetimeDependence
240+
public var neYielded: lifetime_depend_infer.NEImmortal {
241+
_read
242+
_modify
243+
}
244+
#endif
245+
}
246+
public struct NonescapableSelfAccessors : ~Swift.Escapable {
247+
public var ne: lifetime_depend_infer.NE
248+
#if $LifetimeDependence
249+
public init(ne: lifetime_depend_infer.NE)
250+
#endif
251+
#if $LifetimeDependence
252+
public var neComputed: lifetime_depend_infer.NE {
253+
get
254+
}
255+
#endif
256+
#if $LifetimeDependence
257+
public var neYielded: lifetime_depend_infer.NE {
258+
_read
259+
@lifetime(borrow self)
260+
_modify
261+
}
262+
#endif
263+
}
264+
public struct NoncopyableSelfAccessors : ~Copyable & ~Escapable {
265+
public var ne: lifetime_depend_infer.NE
266+
#if $LifetimeDependence
267+
public var neComputed: lifetime_depend_infer.NE {
268+
get
269+
set
270+
}
271+
#endif
272+
#if $LifetimeDependence
273+
public var neYielded: lifetime_depend_infer.NE {
274+
_read
275+
@lifetime(borrow self)
276+
_modify
277+
}
278+
#endif
279+
#if $LifetimeDependence
280+
public var neComputedLifetime: lifetime_depend_infer.NE {
281+
@lifetime(self)
282+
get
283+
@lifetime(self)
284+
set
285+
}
286+
#endif
287+
#if $LifetimeDependence
288+
public var neYieldedLifetime: lifetime_depend_infer.NE {
289+
@lifetime(self)
290+
_read
291+
@lifetime(self)
292+
_modify
293+
}
294+
#endif
295+
#if $LifetimeDependence
296+
public var neComputedCopy: lifetime_depend_infer.NE {
297+
@lifetime(copy self)
298+
get
299+
@lifetime(copy self)
300+
set
301+
}
302+
#endif
303+
#if $LifetimeDependence
304+
public var neYieldedCopy: lifetime_depend_infer.NE {
305+
@lifetime(copy self)
306+
_read
307+
@lifetime(copy self)
308+
_modify
309+
}
310+
#endif
311+
#if $LifetimeDependence
312+
public var neComputedBorrow: lifetime_depend_infer.NE {
313+
@lifetime(borrow self)
314+
get
315+
@lifetime(borrow self)
316+
set
317+
}
318+
#endif
319+
#if $LifetimeDependence
320+
public var neYieldedBorrow: lifetime_depend_infer.NE {
321+
@lifetime(borrow self)
322+
_read
323+
@lifetime(borrow self)
324+
_modify
325+
}
326+
#endif
327+
}
328+
public struct NonEscapableMutableSelf : ~Swift.Escapable {
329+
#if $LifetimeDependence
330+
public mutating func mutatingMethodNoParam()
331+
#endif
332+
#if $LifetimeDependence
333+
@lifetime(self: self)
334+
public mutating func mutatingMethodNoParamLifetime()
335+
#endif
336+
#if $LifetimeDependence
337+
@lifetime(self: copy self)
338+
public mutating func mutatingMethodNoParamCopy()
339+
#endif
340+
#if $LifetimeDependence
341+
@lifetime(self: self)
342+
public mutating func mutatingMethodOneParamLifetime(_: lifetime_depend_infer.NE)
343+
#endif
344+
#if $LifetimeDependence
345+
@lifetime(copy self)
346+
public mutating func mutatingMethodOneParamCopy(_: lifetime_depend_infer.NE)
347+
#endif
348+
#if $LifetimeDependence
349+
@lifetime(borrow self)
350+
public mutating func mutatingMethodOneParamBorrow(_: lifetime_depend_infer.NE)
351+
#endif
352+
}
Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
// RUN: %target-typecheck-verify-swift \
2+
// RUN: -I %S/Inputs \
3+
// RUN: -enable-experimental-feature LifetimeDependence \
4+
// RUN: -enable-experimental-lifetime-dependence-inference
5+
6+
// REQUIRES: swift_feature_LifetimeDependence
7+
8+
// Test that type checking continues to handle inference of lifetime
9+
// dependencies that may be required in older (early
10+
// 2025) .swiftinterface files. Source-level type checking is more strict.
11+
12+
import lifetime_depend_infer

0 commit comments

Comments
 (0)