File: inverse_signatures.swift

package info (click to toggle)
swiftlang 6.0.3-2
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid, trixie
  • size: 2,519,992 kB
  • sloc: cpp: 9,107,863; ansic: 2,040,022; asm: 1,135,751; python: 296,500; objc: 82,456; f90: 60,502; lisp: 34,951; pascal: 19,946; sh: 18,133; perl: 7,482; ml: 4,937; javascript: 4,117; makefile: 3,840; awk: 3,535; xml: 914; fortran: 619; cs: 573; ruby: 573
file content (208 lines) | stat: -rw-r--r-- 7,889 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
// RUN: %target-swift-frontend \
// RUN:   -enable-experimental-feature NonescapableTypes \
// RUN:   -enable-experimental-feature SuppressedAssociatedTypes \
// RUN:   -verify -typecheck %s -debug-generic-signatures \
// RUN:   -debug-inverse-requirements 2>&1 | %FileCheck %s --implicit-check-not "error:"

// CHECK-LABEL: (file).genericFn@
// CHECK: Generic signature: <T where T : Copyable, T : Escapable>
func genericFn<T>(_ t: T) {}

// CHECK-LABEL: .withInverse1@
// CHECK: Generic signature: <T where T : Escapable>
func withInverse1<T: ~Copyable>(_ t: borrowing T) {}

// CHECK-LABEL: .withInverse2@
// CHECK: Generic signature: <T where T : Copyable>
func withInverse2<T: ~Escapable>(_ t: borrowing T) {}

// CHECK-LABEL: .withInverse3@
// CHECK: Generic signature: <T>
func withInverse3<T: ~Copyable & ~Escapable>(_ t: borrowing T) {}

// CHECK-LABEL: .where1@
// CHECK: Generic signature: <T where T : Escapable>
func where1<T>(_ t: borrowing T) where T: ~Copyable {}

// CHECK-LABEL: .where2@
// CHECK: Generic signature: <T where T : NoCopyP>
func where2<T>(_ t: borrowing T) where T: NoCopyP, T: ~Copyable {}

// CHECK-LABEL: .where3@
// CHECK: Generic signature: <T where T : Escapable, T : Empty>
func where3<T>(_ t: borrowing T) where T: Empty, T: ~Copyable {}

// CHECK-LABEL: .where4@
// CHECK: Generic signature: <T where T : Copyable>
func where4<T>(_ t: borrowing T) where T: ~Escapable {}

// CHECK-LABEL: .where5@
// CHECK: Generic signature: <T where T : Copyable, T : Empty>
func where5<T>(_ t: borrowing T) where T: Empty, T: ~Escapable {}

// CHECK-LABEL: .where6@
// CHECK: Generic signature: <T where T : Escapable, T : Empty>
func where6<T>(_ t: borrowing T) where T: Empty, T: ~Copyable {}

// CHECK-LABEL: .compose1@
// CHECK: Generic signature: <T where T : NoCopyP>
func compose1<T: NoCopyP & ~Copyable>(_ t: borrowing T) {}

// CHECK-LABEL: .compose3@
// CHECK: Canonical generic signature: <τ_0_0 where τ_0_0 : NoCopyP>
func compose3(_ t: inout some NoCopyP & ~Copyable) {}

// CHECK-LABEL: .f1@
// CHECK: Generic signature: <T where T : Copyable, T : NoCopyP>
func f1<T: NoCopyP>(_ t: T) {}

// CHECK-LABEL: .withSome@
// CHECK: Canonical generic signature: <τ_0_0 where τ_0_0 : Copyable, τ_0_0 : Escapable>
func withSome(_ t: some Any) {}

// CHECK-LABEL: .withSomeEmpty@
// CHECK: Canonical generic signature: <τ_0_0 where τ_0_0 : Copyable, τ_0_0 : Escapable, τ_0_0 : Empty>
func withSomeEmpty(_ t: some Empty) {}

// CHECK-LABEL: .withSomeProto@
// CHECK: Canonical generic signature: <τ_0_0 where τ_0_0 : Copyable, τ_0_0 : NoCopyP>
func withSomeProto(_ t: some NoCopyP) {}

// CHECK-LABEL: .withInverseSome@
// CHECK: Canonical generic signature: <τ_0_0 where τ_0_0 : Escapable>
func withInverseSome(_ t: borrowing some ~Copyable) {}

// CHECK-LABEL: .checkAnyObject@
// CHECK: Canonical generic signature: <τ_0_0 where τ_0_0 : AnyObject, τ_0_0 : Copyable, τ_0_0 : Escapable>
func checkAnyObject<Result>(_ t: Result) where Result: AnyObject {}

// CHECK-LABEL: .checkSoup@
// CHECK: Canonical generic signature: <τ_0_0 where τ_0_0 : Soup>
class Soup {}
func checkSoup<T>(_ t: T) where T: Soup {}

// CHECK-LABEL: .S1@
// CHECK: Generic signature: <T where T : Copyable, T : Escapable>
struct S1<T> {}

// CHECK-LABEL: .S1_I@
// CHECK: Generic signature: <T where T : Escapable>
struct S1_I<T: ~Copyable> {}

// CHECK-LABEL: .C1@
// CHECK: Generic signature: <T, U where T : Copyable, T : Escapable, U : Copyable, U : Escapable>
class C1<T, U> {}

// CHECK-LABEL: .C1_IC@
// CHECK: Generic signature: <T, U where T : Escapable, U : Copyable, U : Escapable>
class C1_IC<T: ~Copyable, U> {}

// CHECK-LABEL: .C1_CI@
// CHECK: Generic signature: <T, U where T : Copyable, T : Escapable, U : Escapable>
class C1_CI<T, U> where U: ~Copyable {}

// CHECK-LABEL: .C1_II@
// CHECK: Generic signature: <T, U where T : Escapable, U : Escapable>
class C1_II<T: ~Copyable, U: ~Copyable> {}

// CHECK-LABEL: .Empty@
// CHECK: Requirement signature: <Self>
protocol Empty: ~Copyable, ~Escapable {}

// CHECK-LABEL: .NoEscapeP@
// CHECK: Requirement signature: <Self where Self : Copyable>
protocol NoEscapeP: ~Escapable {}

// CHECK-LABEL: .NoEscapeP2@
// CHECK: Requirement signature: <Self where Self : NoEscapeP>
protocol NoEscapeP2 where Self: NoEscapeP & ~Escapable {}

// CHECK-LABEL: .ForgotTildeEscape@
// CHECK: Requirement signature: <Self where Self : Escapable, Self : NoEscapeP>
protocol ForgotTildeEscape where Self: NoEscapeP {}

// CHECK-LABEL: .NoCopyP@
// CHECK: Requirement signature: <Self where Self : Escapable>
protocol NoCopyP: ~Copyable {}

// CHECK-LABEL: .NoCopyP2@
// CHECK: Requirement signature: <Self where Self : NoCopyP>
protocol NoCopyP2 where Self: ~Copyable & NoCopyP {}

// CHECK-LABEL: .CopyP@
// CHECK: Requirement signature: <Self where Self : Copyable, Self : Escapable>
protocol CopyP {}

// CHECK-LABEL: .CopyP2@
// CHECK: Requirement signature: <Self where Self : CopyP>
protocol CopyP2: CopyP {}

// CHECK-LABEL: .CopyInheritsNC@
// CHECK: Requirement signature: <Self where Self : Copyable, Self : NoCopyP>
protocol CopyInheritsNC: NoCopyP {}

// CHECK-LABEL: .P2@
// CHECK: <Self where Self : Copyable, Self : Escapable, Self.[P2]A : Copyable, Self.[P2]A : Escapable>
protocol P2 { associatedtype A }

// CHECK-LABEL: .P2_IC@
// CHECK: <Self where Self : Escapable, Self.[P2_IC]A : Copyable, Self.[P2_IC]A : Escapable>
protocol P2_IC: ~Copyable { associatedtype A }

// CHECK-LABEL: .P2_CI@
// CHECK: Requirement signature: <Self where Self : Copyable, Self : Escapable, Self.[P2_CI]A : Escapable>
protocol P2_CI { associatedtype A: ~Copyable }

// CHECK-LABEL: .P2_II@
// CHECK: Requirement signature: <Self where Self : Escapable, Self.[P2_II]A : Escapable>
protocol P2_II: ~Copyable { associatedtype A: ~Copyable }

// CHECK-LABEL: .P3@
// CHECK: Requirement signature: <Self where Self.[P3]B : Copyable>
protocol P3 where Self: (~Copyable & ~Escapable) { associatedtype B: ~Escapable }

// CHECK-LABEL: .P4@
// CHECK: Requirement signature: <Self where Self : Copyable, Self.[P4]B : Copyable, Self.[P4]C : Escapable>
protocol P4: ~Escapable {
  associatedtype B: ~Escapable
  associatedtype C: ~Copyable
  associatedtype D: ~Escapable, ~Copyable
}

// CHECK-LABEL: .Explicit@
// CHECK: Requirement signature: <Self where Self : Copyable, Self : Escapable, Self.[Explicit]Elm : Copyable, Self.[Explicit]Elm : Escapable>
protocol Explicit: Copyable, Escapable {
  associatedtype Elm: Copyable, Escapable
}

// CHECK-LABEL: .Cond@
// CHECK: Generic signature: <T where T : Escapable>
// CHECK-NEXT: Canonical generic signature: <τ_0_0 where τ_0_0 : Escapable>
struct Cond<T: ~Copyable>: ~Copyable {}

// CHECK-LABEL: ExtensionDecl line={{.*}} base=Cond
// CHECK: <T where T : Copyable, T : Escapable>
// CHECK-NEXT: Canonical generic signature: <τ_0_0 where τ_0_0 : Copyable, τ_0_0 : Escapable>

// CHECK-LABEL: ExtensionDecl line={{.*}} base=Cond
// CHECK:       (normal_conformance type="Cond<T>" protocol="Copyable"
// CHECK-NEXT:       (requirement "T" conforms_to "Copyable"))
extension Cond: Copyable where T: Copyable {}


// CHECK-LABEL: .FullyGenericArg@
// CHECK: Generic signature: <T>
// CHECK-NEXT: Canonical generic signature: <τ_0_0>
struct FullyGenericArg<T: ~Escapable & ~Copyable> {}

// CHECK-LABEL: StructDecl name=FullyGenericArg
// CHECK-NEXT:    (builtin_conformance type="FullyGenericArg<T>" protocol="Copyable")
// CHECK-NEXT:    (builtin_conformance type="FullyGenericArg<T>" protocol="Escapable")

// CHECK-LABEL: ExtensionDecl line={{.*}} base=FullyGenericArg
// CHECK: Generic signature: <T>
// CHECK-NEXT: Canonical generic signature: <τ_0_0>

// CHECK-LABEL: ExtensionDecl line={{.*}} base=FullyGenericArg
// CHECK-NEXT: (normal_conformance type="FullyGenericArg<T>" protocol="Empty")
extension FullyGenericArg: Empty where T: ~Copyable, T: ~Escapable {}