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
Add tests for basic LifetimeDependence requirements
Test each basic case that requires LifetimeDependences,
first without enabling the LifetimeDependence feature,
then without specifying the kind of dependence.
// These tests complement lifetime_depend_nofeature.swift. If you add a test here, add one there.
12
+
13
+
// Check that missing lifetime dependencies are diagnosed. Enabling LifetimeDependencies will issue more detailed
14
+
// diagnostics.
15
+
16
+
// Allow empty initialization.
17
+
structEmptyNonEscapable:~Escapable {} // OK - no dependence
18
+
19
+
// Don't allow non-Escapable return values.
20
+
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)'}}
21
+
22
+
func neInout(span:inoutRawSpan){} // OK - inferred
23
+
24
+
structS{
25
+
func neReturn(span:RawSpan)->RawSpan{ span } // expected-error{{a method with a ~Escapable result requires '@lifetime(...)}}
26
+
27
+
func neInout(span:inoutRawSpan){} // OK - inferred
28
+
}
29
+
30
+
classC{
31
+
func neReturn(span:RawSpan)->RawSpan{ span } // expected-error{{a method with a ~Escapable result requires '@lifetime(...)'}}
32
+
33
+
func neInout(span:inoutRawSpan){} // OK - inferred
// These tests complement lifetime_depend_noattr.swift. If you add a test here, add one there.
9
+
10
+
// Check that functions that require lifetime dependence are prohibited without the flag.
11
+
12
+
// Don't allow empty initialization.
13
+
structEmptyNonEscapable:~Escapable {} // expected-error{{an implicit initializer with a ~Escapable result requires '-enable-experimental-feature LifetimeDependence'}}
14
+
15
+
// Don't allow non-Escapable return values.
16
+
func neReturn(span:RawSpan)->RawSpan{ span } // expected-error{{a function with a ~Escapable result requires '-enable-experimental-feature LifetimeDependence'}}
17
+
18
+
func neInout(span:inoutRawSpan){} // expected-error{{a function with a ~Escapable 'inout' parameter requires '-enable-experimental-feature LifetimeDependence'}}
19
+
20
+
structS{
21
+
func neReturn(span:RawSpan)->RawSpan{ span } // expected-error{{a method with a ~Escapable result requires '-enable-experimental-feature LifetimeDependence'}}
22
+
23
+
func neInout(span:inoutRawSpan){} // expected-error{{a method with a ~Escapable 'inout' parameter requires '-enable-experimental-feature LifetimeDependence'}}
24
+
}
25
+
26
+
classC{
27
+
func neReturn(span:RawSpan)->RawSpan{ span } // expected-error{{a method with a ~Escapable result requires '-enable-experimental-feature LifetimeDependence'}}
28
+
29
+
func neInout(span:inoutRawSpan){} // expected-error{{a method with a ~Escapable 'inout' parameter requires '-enable-experimental-feature LifetimeDependence'}}
0 commit comments