Skip to content

Commit d6486e2

Browse files
author
Amritpan Kaur
committed
Add test
1 parent dda0f50 commit d6486e2

File tree

1 file changed

+16
-0
lines changed

1 file changed

+16
-0
lines changed

test/Constraints/keypath.swift

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -206,3 +206,19 @@ func rdar85458997() {
206206
_ = S(\.name)
207207
// expected-error@-1 {{cannot infer key path type from context; consider explicitly specifying a root type}} {{10-10=<#Root#>}}
208208
}
209+
210+
// https://github.com/apple/swift/issues/65965 - failed to produce correct types for key path capability mismatch
211+
func issue_65965() {
212+
struct S {
213+
var s: String
214+
let v: String
215+
}
216+
217+
let refKP: ReferenceWritableKeyPath<S, String>
218+
refKP = \.s
219+
// expected-error@-1 {{key path value type 'WritableKeyPath<S, String>' cannot be converted to contextual type 'ReferenceWritableKeyPath<S, String>'}}
220+
221+
let writeKP: WritableKeyPath<S, String>
222+
writeKP = \.v
223+
// expected-error@-1 {{key path value type 'KeyPath<S, String>' cannot be converted to contextual type 'WritableKeyPath<S, String>'}}
224+
}

0 commit comments

Comments
 (0)