You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
@_lifetime // expected-error{{expected '(' after lifetime dependence specifier}}
23
-
func testMissingLParenError(_ ne:NE)->NE{ // expected-error{{cannot infer the lifetime dependence scope on a function with a ~Escapable parameter, specify '@_lifetime(borrow ne)' or '@_lifetime(copy ne)'}}
23
+
func testMissingLParenError(_ ne:NE)->NE{
24
24
ne
25
25
}
26
26
27
27
@_lifetime() // expected-error{{expected 'copy', 'borrow', or '&' followed by an identifier, index or 'self' in lifetime dependence specifier}}
28
-
func testMissingDependence(_ ne:NE)->NE{ // expected-error{{cannot infer the lifetime dependence scope on a function with a ~Escapable parameter, specify '@_lifetime(borrow ne)' or '@_lifetime(copy ne)'}}
func sameTypeConsumingParam(ne:consumingNE)->NE{ ne }
33
+
34
+
func sameTypeBorrowingParam(ne:borrowingNE)->NE{ ne }
35
+
36
+
func sameTypeInoutParam(ne:inoutNE)->NE{ ne } // expected-error{{cannot infer the lifetime dependence scope on a function with a ~Escapable parameter, specify '@_lifetime(borrow ne)' or '@_lifetime(copy ne)'}}
func sameTypeParam_otherTypeParam(ne:NE, c:C)->NE{ ne }
41
+
42
+
func sameTypeParam_sameTypeInoutParam(ne:NE, mutNE:inoutNE)->NE{ ne }
43
+
44
+
structNonEscapable<T>:~Escapable {
45
+
@_lifetime(immortal)
46
+
init(){}
47
+
48
+
init(ne:Self){}
49
+
50
+
init(c:C){} // expected-error{{cannot borrow the lifetime of 'c', which has consuming ownership on an initializer}}
51
+
52
+
init(ne:Self, c:C){}
53
+
54
+
init<U>(ne:Self, u:U){}
55
+
56
+
init<U>(neNominal:NonEscapable<T>, u:U){}
57
+
58
+
init<U>(other:NonEscapable<U>){} // expected-error{{cannot infer the lifetime dependence scope on an initializer with a ~Escapable parameter, specify '@_lifetime(borrow other)' or '@_lifetime(copy other)'}}
func otherNominalTypeSelf_genericParam<U>(u:U)->NonEscapable<U>{NonEscapable<U>()} // expected-error{{a method with a ~Escapable result requires '@_lifetime(...)'}}
79
+
}
80
+
81
+
protocolNonEscapableProtocol:~Escapable {
82
+
@_lifetime(immortal)
83
+
staticfunc create()->Self
84
+
85
+
init(ne:Self)
86
+
87
+
init<U>(ne:Self, u:U)
88
+
89
+
init(ne:someNonEscapableProtocol, c:C) // expected-error{{an initializer with a ~Escapable result requires '@_lifetime(...)'}}
90
+
91
+
init(neProtocol:anyNonEscapableProtocol, c:C) // expected-error{{an initializer with a ~Escapable result requires '@_lifetime(...)'}}
92
+
93
+
func sameArchetypeSelf()->Self
94
+
95
+
mutatingfunc sameArchetypeMutatingSelf()->Self // expected-error{{a mutating method with a ~Escapable result requires '@_lifetime(...)'}}
func twoParamsInout_NEResult(c:inoutC, _:Int)->NEImmortal{NEImmortal()} // expected-error{{a function with a ~Escapable result requires '@_lifetime(...)'}}
73
186
74
-
func neParam_NEResult(ne:NE)->NE{ ne } // expected-error{{cannot infer the lifetime dependence scope on a function with a ~Escapable parameter, specify '@_lifetime(borrow ne)' or '@_lifetime(copy ne)'}}
187
+
func neParam_NEResult(ne:NE)->NE{ ne }
75
188
76
189
@_lifetime(ne) // expected-error{{cannot infer the lifetime dependence scope on a function with a ~Escapable parameter, specify '@_lifetime(borrow ne)' or '@_lifetime(copy ne)'}}
77
190
func neParamLifetime_NEResult(ne:NE)->NE{ ne }
78
191
79
-
func neParamBorrow_NEResult(ne:borrowingNE)->NE{ ne } // expected-error{{cannot infer the lifetime dependence scope on a function with a ~Escapable parameter, specify '@_lifetime(borrow ne)' or '@_lifetime(copy ne)'}}
192
+
func neParamBorrow_NEResult(ne:borrowingNE)->NE{ ne }
80
193
81
194
@_lifetime(ne) // expected-error{{cannot infer the lifetime dependence scope on a function with a ~Escapable parameter, specify '@_lifetime(borrow ne)' or '@_lifetime(copy ne)'}}
82
195
func neParamBorrowLifetime_NEResult(ne:borrowingNE)->NE{ ne }
83
196
84
-
func neParamConsume_NEResult(ne:consumingNE)->NE{ ne } // expected-error{{cannot infer the lifetime dependence scope on a function with a ~Escapable parameter, specify '@_lifetime(borrow ne)' or '@_lifetime(copy ne)'}}
197
+
func neParamConsume_NEResult(ne:consumingNE)->NE{ ne }
85
198
86
199
@_lifetime(ne) // expected-error{{cannot infer the lifetime dependence scope on a function with a ~Escapable parameter, specify '@_lifetime(borrow ne)' or '@_lifetime(copy ne)'}}
87
200
func neParamConsumeLifetime_NEResult(ne:consumingNE)->NE{ ne }
88
201
89
-
func neParam_IntParam_NEResult(ne:NE, _:Int)->NE{ ne } // expected-error{{a function with a ~Escapable result requires '@_lifetime(...)'}}
202
+
func neParam_IntParam_NEResult(ne:NE, _:Int)->NE{ ne }
func noParam_NEResult()->NonEscapableSelf{self} // expected-error{{cannot infer the lifetime dependence scope on a method with a ~Escapable parameter, specify '@_lifetime(borrow self)' or '@_lifetime(copy self)'}}
317
+
extensionNonEscapable /* where Self: ~Escapable */{
318
+
func noParam_NEResult()->NonEscapable{self}
206
319
207
320
@_lifetime(self) // expected-error{{cannot infer the lifetime dependence scope on a method with a ~Escapable parameter, specify '@_lifetime(borrow self)' or '@_lifetime(copy self)'}}
mutatingfunc mutating_noParam_NEResult()->NonEscapableSelf{self} // expected-error{{a mutating method with a ~Escapable result requires '@_lifetime(...)'}}
329
+
mutatingfunc mutating_noParam_NEResult()->NonEscapable{self} // expected-error{{a mutating method with a ~Escapable result requires '@_lifetime(...)'}}
217
330
218
331
@_lifetime(self) // expected-error{{cannot infer the lifetime dependence scope on a mutating method with a ~Escapable parameter, specify '@_lifetime(borrow self)' or '@_lifetime(copy self)'}}
func oneParam_NEResult(_:Int)->NonEscapableSelf{self} // expected-error{{a method with a ~Escapable result requires '@_lifetime(...)'}}
340
+
func oneParam_NEResult(_:Int)->NonEscapable{self}
228
341
229
342
@_lifetime(self) // expected-error{{cannot infer the lifetime dependence scope on a method with a ~Escapable parameter, specify '@_lifetime(borrow self)' or '@_lifetime(copy self)'}}
mutatingfunc mutating_oneParam_NEResult(_:Int)->NonEscapableSelf{self} // expected-error{{a mutating method with a ~Escapable result requires '@_lifetime(...)'}}
351
+
mutatingfunc mutating_oneParam_NEResult(_:Int)->NonEscapable{self} // expected-error{{a mutating method with a ~Escapable result requires '@_lifetime(...)'}}
239
352
240
353
@_lifetime(self) // expected-error{{cannot infer the lifetime dependence scope on a mutating method with a ~Escapable parameter, specify '@_lifetime(borrow self)' or '@_lifetime(copy self)'}}
mutatingfunc mutating_inoutParam_NEResult(a:inoutNE)->NEImmortal{NEImmortal()} // expected-error{{a mutating method with a ~Escapable result requires '@_lifetime(...)'}}
func inoutParam_inoutNEParam_void(_:inoutNE, _:inoutNE){} // OK
265
378
379
+
266
380
func inoutNEParam_NEResult(ne:inoutNE)->NE{ ne } // expected-error{{cannot infer the lifetime dependence scope on a function with a ~Escapable parameter, specify '@_lifetime(borrow ne)' or '@_lifetime(copy ne)'}}
0 commit comments