Skip to content

Commit e11f167

Browse files
author
Nathan Hawes
authored
Merge pull request #32165 from nathawes/add-regression-test-for-dynamic-member-lookup-indexing-crasher
[test] Add indexing regression test case for @dynamicMemberLookup on a protocol.
2 parents 96a5c81 + 1f01103 commit e11f167

File tree

1 file changed

+21
-0
lines changed

1 file changed

+21
-0
lines changed

test/Index/index_keypath_member_lookup.swift

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -137,3 +137,24 @@ func testExplicit(r: Lens<Rectangle>, a: Lens<[Int]>) {
137137
// CHECK: [[EA_LINE]]:8 | instance-property/subscript/Swift | subscript(dynamicMember:) | [[SUB_USR]] | Ref,Read,RelCont | rel: 1
138138
// CHECK: [[EA_LINE]]:26 | instance-property/subscript/Swift | subscript(_:) | s:SayxSicip | Ref,Read,RelCont | rel: 1
139139
}
140+
141+
// Don't crash: rdar63558609
142+
//
143+
@dynamicMemberLookup
144+
protocol Foo {
145+
var prop: Bar {get}
146+
// CHECK: [[@LINE-1]]:7 | instance-property/Swift | prop | [[PROP_USR:.*]] | Def,RelChild | rel: 1
147+
}
148+
struct Bar {
149+
let enabled = false
150+
}
151+
extension Foo {
152+
subscript<T>(dynamicMember keyPath: KeyPath<Bar,T>) -> T {
153+
// CHECK: [[@LINE-1]]:3 | instance-property/subscript/Swift | subscript(dynamicMember:) | [[SUB2_USR:.*]] | Def,RelChild | rel: 1
154+
// CHECK: [[@LINE-2]]:60 | instance-method/acc-get/Swift | getter:subscript(dynamicMember:) | {{.*}} | Def,Dyn,RelChild,RelAcc | rel: 1
155+
// CHECK-NEXT: RelChild,RelAcc | instance-property/subscript/Swift | subscript(dynamicMember:) | [[SUB2_USR]]
156+
157+
prop[keyPath: keyPath]
158+
// CHECK: [[@LINE-1]]:5 | instance-property/Swift | prop | [[PROP_USR]] | Ref,Read,RelCont | rel: 1
159+
}
160+
}

0 commit comments

Comments
 (0)