@@ -205,3 +205,32 @@ struct OptionalWrapper<Value> { // expected-note {{'Value' declared as parameter
205
205
// expected-error@+2 {{generic parameter 'Value' could not be inferred}} expected-note@+2 {{}}
206
206
// expected-error@+1 {{property type 'Int' does not match 'wrappedValue' type 'Value?'}}
207
207
func testWrappedValueMismatch( @OptionalWrapper value: Int ) { }
208
+
209
+ @propertyWrapper
210
+ struct ProjectionWrapper < Value> {
211
+ var wrappedValue : Value
212
+ var projectedValue : Self { self }
213
+ init ( projectedValue: Self ) { self = projectedValue }
214
+ }
215
+
216
+ func testInvalidWrapperInference( ) {
217
+ struct S < V> {
218
+ static func test( _ keyPath: KeyPath < V , String > ) { } // expected-note {{'test' declared here}}
219
+ }
220
+
221
+ // expected-error@+1 {{trailing closure passed to parameter of type 'KeyPath<Int, String>' that does not accept a closure}}
222
+ S < Int > . test { $value in }
223
+ // expected-error@+1 {{cannot convert value of type '(_) -> ()' to expected argument type 'KeyPath<Int, String>'}}
224
+ S< Int> . test( { $value in } )
225
+
226
+ func testGenericClosure< T> ( _ closure: T ) { }
227
+ // FIXME: the following error should use the name of the closure parameter.
228
+ // It's not anonymous, even though it starts with $
229
+ // expected-error@+1 {{unable to infer type of a closure parameter $0 in the current context}}
230
+ testGenericClosure { $value in }
231
+ testGenericClosure { ( $value: ProjectionWrapper < Int > ) in } // okay
232
+
233
+ func testExtraParameter( _ closure: ( ) -> Void ) { }
234
+ // expected-error@+1 {{contextual closure type '() -> Void' expects 0 arguments, but 1 was used in closure body}}
235
+ testExtraParameter { $value in }
236
+ }
0 commit comments