Skip to content

Commit 15e06c5

Browse files
committed
Add test case from rdar://problem/54322807.
1 parent 6d3c678 commit 15e06c5

File tree

1 file changed

+21
-0
lines changed

1 file changed

+21
-0
lines changed

test/Constraints/keypath.swift

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -34,3 +34,24 @@ class Demo {
3434
let some = Some(keyPath: \Demo.here)
3535
// expected-error@-1 {{cannot convert value of type 'ReferenceWritableKeyPath<Demo, (() -> Void)?>' to expected argument type 'KeyPath<_, ((_) -> Void)?>'}}
3636

37+
// rdar://problem/54322807
38+
struct X<T> {
39+
init(foo: KeyPath<T, Bool>) { }
40+
init(foo: KeyPath<T, Bool?>) { }
41+
}
42+
43+
struct Wibble {
44+
var boolProperty = false
45+
}
46+
47+
struct Bar {
48+
var optWibble: Wibble? = nil
49+
}
50+
51+
class Foo {
52+
var optBar: Bar? = nil
53+
}
54+
55+
func testFoo<T: Foo>(_: T) {
56+
let _: X<T> = .init(foo: \.optBar!.optWibble?.boolProperty)
57+
}

0 commit comments

Comments
 (0)