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
198
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)'}}
199
+
func neParam_NEResult(ne:NE)->NE{ ne }
75
200
76
201
@_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
202
func neParamLifetime_NEResult(ne:NE)->NE{ ne }
78
203
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)'}}
204
+
func neParamBorrow_NEResult(ne:borrowingNE)->NE{ ne }
80
205
81
206
@_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
207
func neParamBorrowLifetime_NEResult(ne:borrowingNE)->NE{ ne }
83
208
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)'}}
209
+
func neParamConsume_NEResult(ne:consumingNE)->NE{ ne }
85
210
86
211
@_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
212
func neParamConsumeLifetime_NEResult(ne:consumingNE)->NE{ ne }
88
213
89
-
func neParam_IntParam_NEResult(ne:NE, _:Int)->NE{ ne } // expected-error{{a function with a ~Escapable result requires '@_lifetime(...)'}}
214
+
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)'}}
329
+
extensionNonEscapable /* where Self: ~Escapable */{
330
+
func noParam_NEResult()->NonEscapable{self}
206
331
207
332
@_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(...)'}}
341
+
mutatingfunc mutating_noParam_NEResult()->NonEscapable{self} // expected-error{{a mutating method with a ~Escapable result requires '@_lifetime(...)'}}
217
342
218
343
@_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(...)'}}
352
+
func oneParam_NEResult(_:Int)->NonEscapable{self}
228
353
229
354
@_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(...)'}}
363
+
mutatingfunc mutating_oneParam_NEResult(_:Int)->NonEscapable{self} // expected-error{{a mutating method with a ~Escapable result requires '@_lifetime(...)'}}
239
364
240
365
@_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
390
391
+
266
392
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