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 }
31
+
32
+
func sameTypeBorrowingParam(ne:borrowingNE)->NE{ ne }
33
+
34
+
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 twoParamsInout_NEResult(c:inoutC, _:Int)->NEImmortal{NEImmortal()} // expected-error{{a function with a ~Escapable result requires '@_lifetime(...)'}}
73
113
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)'}}
114
+
func neParam_NEResult(ne:NE)->NE{ ne }
75
115
76
116
@_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
117
func neParamLifetime_NEResult(ne:NE)->NE{ ne }
78
118
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)'}}
119
+
func neParamBorrow_NEResult(ne:borrowingNE)->NE{ ne }
80
120
81
121
@_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
122
func neParamBorrowLifetime_NEResult(ne:borrowingNE)->NE{ ne }
83
123
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)'}}
124
+
func neParamConsume_NEResult(ne:consumingNE)->NE{ ne }
85
125
86
126
@_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
127
func neParamConsumeLifetime_NEResult(ne:consumingNE)->NE{ ne }
88
128
89
-
func neParam_IntParam_NEResult(ne:NE, _:Int)->NE{ ne } // expected-error{{a function with a ~Escapable result requires '@_lifetime(...)'}}
129
+
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)'}}
244
+
extensionNonEscapableSelf /* where Self: ~Escapable */{
245
+
func noParam_NEResult()->NonEscapableSelf{self}
206
246
207
247
@_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)'}}
@_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)'}}
func inoutParam_inoutNEParam_void(_:inoutNE, _:inoutNE){} // OK
265
305
306
+
266
307
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)'}}
Copy file name to clipboardExpand all lines: test/Sema/lifetime_depend_noattr.swift
+3-3Lines changed: 3 additions & 3 deletions
Original file line number
Diff line number
Diff line change
@@ -13,18 +13,18 @@
13
13
structEmptyNonEscapable:~Escapable {} // OK - no dependence
14
14
15
15
// Don't allow non-Escapable return values.
16
-
func neReturn(span:RawSpan)->RawSpan{ span } // expected-error{{cannot infer the lifetime dependence scope on a function with a ~Escapable parameter, specify '@_lifetime(borrow span)' or '@_lifetime(copy span)'}}
16
+
func neReturn(span:RawSpan)->RawSpan{ span }
17
17
18
18
func neInout(span:inoutRawSpan){} // OK - inferred
19
19
20
20
structS{
21
-
func neReturn(span:RawSpan)->RawSpan{ span } // expected-error{{a method with a ~Escapable result requires '@_lifetime(...)}}
21
+
func neReturn(span:RawSpan)->RawSpan{ span }
22
22
23
23
func neInout(span:inoutRawSpan){} // OK - inferred
24
24
}
25
25
26
26
classC{
27
-
func neReturn(span:RawSpan)->RawSpan{ span } // expected-error{{a method with a ~Escapable result requires '@_lifetime(...)'}}
27
+
func neReturn(span:RawSpan)->RawSpan{ span }
28
28
29
29
func neInout(span:inoutRawSpan){} // OK - inferred
0 commit comments