Skip to content

Commit ba1b67a

Browse files
committed
[TypeChecker] NFC: Add a couple test-cases of partial key path inference
1 parent 0c75593 commit ba1b67a

File tree

1 file changed

+23
-0
lines changed

1 file changed

+23
-0
lines changed

test/expr/unary/keypath/keypath.swift

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1118,6 +1118,29 @@ func test_kp_as_function_mismatch() {
11181118

11191119
}
11201120

1121+
func test_partial_keypath_inference() {
1122+
// rdar://problem/34144827
1123+
1124+
struct S { var i: Int = 0 }
1125+
enum E { case A(pkp: PartialKeyPath<S>) }
1126+
1127+
_ = E.A(pkp: \.i) // Ok
1128+
1129+
// rdar://problem/36472188
1130+
1131+
class ThePath {
1132+
var isWinding:Bool?
1133+
}
1134+
1135+
func walk<T>(aPath: T, forKey: PartialKeyPath<T>) {}
1136+
func walkThePath(aPath: ThePath, forKey: PartialKeyPath<ThePath>) {}
1137+
1138+
func test(path: ThePath) {
1139+
walkThePath(aPath: path, forKey: \.isWinding) // Ok
1140+
walk(aPath: path, forKey: \.isWinding) // Ok
1141+
}
1142+
}
1143+
11211144
// SR-14499
11221145
struct SR14499_A { }
11231146
struct SR14499_B { }

0 commit comments

Comments
 (0)