Skip to content

Commit 7d4db41

Browse files
committed
[TypeChecker] NFC: Add one more test-case for SR-11743
1 parent 2cdd785 commit 7d4db41

File tree

1 file changed

+14
-2
lines changed

1 file changed

+14
-2
lines changed

test/Constraints/keypath_dynamic_member_lookup.swift

Lines changed: 14 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -484,15 +484,27 @@ func testDynamicMemberWithDefault(_ x: SR_11933) {
484484
_ = \SR_11933.[]
485485
}
486486

487+
// SR-11743 - KeyPath Dynamic Member Lookup crash
487488
@dynamicMemberLookup
488-
protocol SR_11743 {
489+
protocol SR_11743_P {
489490
subscript(dynamicMember member: KeyPath<Self, Any>) -> Any { get }
490491
}
491492

492-
extension SR_11743 {
493+
extension SR_11743_P {
493494
subscript(dynamicMember member: KeyPath<Self, Any>) -> Any {
494495
self[keyPath: member] // Ok
495496
// CHECK: function_ref @swift_getAtKeyPath
496497
// CHECK-NEXT: apply %{{.*}}<Self, Any>({{.*}})
497498
}
498499
}
500+
501+
@dynamicMemberLookup
502+
struct SR_11743_Struct {
503+
let value: Int
504+
505+
subscript<T>(dynamicMember member: KeyPath<Self, T>) -> T {
506+
return self[keyPath: member]
507+
// CHECK: function_ref @swift_getAtKeyPath
508+
// CHECK-NEXT: apply %{{.*}}<SR_11743_Struct, T>({{.*}})
509+
}
510+
}

0 commit comments

Comments
 (0)