Skip to content

Commit 021d524

Browse files
authored
[IRGen] Pass component generic sig when emitting key path component f… (#64871)
* [IRGen] Pass component generic sig when emitting key path component for external property rdar://101179225 When no generic environment was present, we passed nullptr, which is not correct when the property uses an external associated type, causing crashes in IRGen. In those cases, we have to pass the component generic sig instead. * Fix test
1 parent 4d1b1d7 commit 021d524

File tree

2 files changed

+28
-1
lines changed

2 files changed

+28
-1
lines changed

lib/IRGen/GenKeyPath.cpp

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -904,7 +904,8 @@ emitKeyPathComponent(IRGenModule &IGM,
904904
reqt.getProtocol());
905905
externalSubArgs.push_back(IGM.emitWitnessTableRefString(
906906
substType, conformance,
907-
genericEnv ? genericEnv->getGenericSignature() : nullptr,
907+
genericEnv ? genericEnv->getGenericSignature() :
908+
componentCanSig,
908909
/*shouldSetLowBit*/ true));
909910
}
910911
});
Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
// RUN: %empty-directory(%t)
2+
// RUN: %target-swift-frontend -disable-availability-checking %s -emit-ir > /dev/null
3+
4+
struct Section: Identifiable {
5+
let id: Int
6+
let items: [any Item]
7+
}
8+
9+
protocol Item: AnyObject, Identifiable {
10+
}
11+
12+
protocol P {
13+
}
14+
15+
struct Iter<D, I, C>: P where D : RandomAccessCollection, I : Hashable {
16+
init(_ xs: D, id: KeyPath<D.Element, I>, f: (D.Element) -> C) {}
17+
}
18+
19+
struct V {
20+
var s: Section
21+
var p: some P {
22+
Iter(s.items, id: \.id) { x in
23+
""
24+
}
25+
}
26+
}

0 commit comments

Comments
 (0)