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
let _:KeyPath<S,Int>= \.foo // expected-error {{key path cannot refer to instance method 'foo()'}}
798
+
// expected-error@-1 {{key path value type '() -> Int' cannot be converted to contextual type 'Int'}}
798
799
let _:KeyPath<S,Int>= \.bar // expected-error {{key path cannot refer to static member 'bar()'}}
799
800
let _ = \S.Type.bar // expected-error {{key path cannot refer to static method 'bar()'}}
800
801
@@ -1094,3 +1095,19 @@ func rdar74711236() {
1094
1095
}()
1095
1096
}
1096
1097
}
1098
+
1099
+
extension String {
1100
+
varfilterOut:(Self)throws->Bool{
1101
+
{ $0.contains("a")}
1102
+
}
1103
+
}
1104
+
1105
+
func test_kp_as_function_mismatch(){
1106
+
leta:[String]=["asd","bcd","def"]
1107
+
1108
+
let _ :(String)->Bool= \.filterOut // expected-error{{key path value type '(String) throws -> Bool' cannot be converted to contextual type 'Bool'}}
1109
+
_ = a.filter(\.filterOut) // expected-error{{key path value type '(String) throws -> Bool' cannot be converted to contextual type 'Bool'}}
1110
+
let _ :(String)->Bool= \String.filterOut // expected-error{{key path value type '(String) throws -> Bool' cannot be converted to contextual type 'Bool'}}
1111
+
_ = a.filter(\String.filterOut) // expected-error{{key path value type '(String) throws -> Bool' cannot be converted to contextual type 'Bool'}}
0 commit comments