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
This PR adds a variadic macro that builds a SwiftAttr string containing
the names of the template type parameters that need to be escapable for
the type to be considered escapable. It also adds logic to interpret
this annotation.
rdar://139065437
WARNING(return_escapable_with_lifetimebound, none, "the returned type '%0' is annotated as escapable; it cannot have lifetime dependencies", (StringRef))
309
309
WARNING(return_nonescapable_without_lifetimebound, none, "the returned type '%0' is annotated as non-escapable; its lifetime dependencies must be annotated", (StringRef))
310
310
311
+
ERROR(unknown_template_parameter,none,
312
+
"template parameter '%0' does not exist", (StringRef))
313
+
ERROR(type_template_parameter_expected,none,
314
+
"template parameter '%0' expected to be a type parameter", (StringRef))
Copy file name to clipboardExpand all lines: test/Interop/Cxx/class/nonescapable-errors.swift
+36-1Lines changed: 36 additions & 1 deletion
Original file line number
Diff line number
Diff line change
@@ -37,6 +37,30 @@ View g(int* x) {
37
37
returnView(x);
38
38
}
39
39
40
+
template<typename F,typename S>
41
+
struct SWIFT_ESCAPABLE_IF(F, S) MyPair {
42
+
F first;
43
+
S second;
44
+
};
45
+
46
+
MyPair<View,Owner> h1(int* x);
47
+
MyPair<Owner,View> h2(int* x);
48
+
MyPair<Owner,Owner> h3(int* x);
49
+
50
+
template<typename F,typename S>
51
+
struct SWIFT_ESCAPABLE_IF(F, Missing) MyPair2{
52
+
F first;
53
+
S second;
54
+
};
55
+
56
+
template<typename F,int S>
57
+
struct SWIFT_ESCAPABLE_IF(F, S) MyType {
58
+
F field;
59
+
};
60
+
61
+
MyPair2<Owner,Owner> i1();
62
+
MyType<Owner,0>i2();
63
+
40
64
//--- test.swift
41
65
42
66
import Test
@@ -50,7 +74,18 @@ public func noAnnotations() -> View {
50
74
// CHECK-NOT: nonescapable.h:19
51
75
f2(nil,nil)
52
76
// CHECK: nonescapable.h:23:6: warning: the returned type 'View' is annotated as non-escapable; its lifetime dependencies must be annotated
53
-
// CHECKL nonescapable.h:23:6: error: cannot infer lifetime dependence, no parameters found that are either ~Escapable or Escapable with a borrowing ownership
77
+
// CHECK: nonescapable.h:23:6: error: cannot infer lifetime dependence, no parameters found that are either ~Escapable or Escapable with a borrowing ownership
54
78
g(nil)
79
+
h1(nil)
80
+
// CHECK: nonescapable.h:33:21: error: cannot infer lifetime dependence, no parameters found that are either ~Escapable or Escapable with a borrowing ownership
81
+
h2(nil)
82
+
// CHECK: nonescapable.h:34:21: error: cannot infer lifetime dependence, no parameters found that are either ~Escapable or Escapable with a borrowing ownership
83
+
h3(nil)
84
+
i1()
85
+
// CHECK: nonescapable.h:38:39: error: template parameter 'Missing' does not exist
86
+
i2()
87
+
// CHECK: nonescapable.h:44:33: error: template parameter 'S' expected to be a type parameter
0 commit comments