@@ -115,10 +115,51 @@ func rethrowsWithThrowsClosure<T : ThrowsClosure>(_ t: T) rethrows {
115
115
116
116
try rethrowsWithThrowsClosure ( ThrowsClosureWitness ( ) )
117
117
118
+ @rethrows protocol RethrowsClosure {
119
+ func doIt( ) throws
120
+ func doIt( _: ( ) throws -> ( ) ) rethrows
121
+ }
122
+
123
+ struct RethrowsClosureWitness : RethrowsClosure {
124
+ func doIt( ) { }
125
+ func doIt( _: ( ) throws -> ( ) ) rethrows { }
126
+ }
127
+
128
+ func rethrowsWithRethrowsClosure< T : RethrowsClosure > ( _ t: T ) rethrows {
129
+ try t. doIt ( ) { }
130
+ }
131
+
132
+ try rethrowsWithRethrowsClosure ( RethrowsClosureWitness ( ) )
133
+
118
134
// Empty protocol
119
135
@rethrows protocol Empty { }
120
136
struct EmptyWitness : Empty { }
121
137
122
138
func takesEmpty< T : Empty > ( _: T ) rethrows { }
123
139
124
- takesEmpty ( EmptyWitness ( ) )
140
+ takesEmpty ( EmptyWitness ( ) )
141
+
142
+ // FIXME: Fix this soundness hole
143
+
144
+ // Note: SimpleThrowsClosure is not @rethrows
145
+ protocol SimpleThrowsClosure {
146
+ func doIt( _: ( ) throws -> ( ) ) rethrows
147
+ }
148
+
149
+ struct ConformsToSimpleThrowsClosure < T : RethrowingProtocol > : SimpleThrowsClosure {
150
+ let t : T
151
+
152
+ // This cannot witness SimpleThrowsClosure.doIt(), because the
153
+ // T : RethrowingProtocol conformance is a source here, but that
154
+ // is not captured in the protocol's requirement signature.
155
+ func doIt( _: ( ) throws -> ( ) ) rethrows {
156
+ try t. source ( )
157
+ }
158
+ }
159
+
160
+ func soundnessHole< T : SimpleThrowsClosure > ( _ t: T ) {
161
+ t. doIt { }
162
+ }
163
+
164
+ // This actually can throw...
165
+ soundnessHole ( ConformsToSimpleThrowsClosure ( t: Throws ( ) ) )
0 commit comments