Skip to content

Commit 36b3d3a

Browse files
committed
AST: Handle PackConformance in SubstitutionMap::lookupConformance()
1 parent 97e6b56 commit 36b3d3a

File tree

2 files changed

+23
-0
lines changed

2 files changed

+23
-0
lines changed

lib/AST/SubstitutionMap.cpp

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -418,6 +418,16 @@ SubstitutionMap::lookupConformance(CanType type, ProtocolDecl *proto) const {
418418

419419
// For the second step, we're looking into the requirement signature for
420420
// this protocol.
421+
if (conformance.isPack()) {
422+
auto pack = conformance.getPack();
423+
conformance = ProtocolConformanceRef(
424+
pack->getAssociatedConformance(step.first, step.second));
425+
if (conformance.isInvalid())
426+
return conformance;
427+
428+
continue;
429+
}
430+
421431
auto concrete = conformance.getConcrete();
422432
auto normal = concrete->getRootNormalConformance();
423433

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
// RUN: %target-swift-frontend -emit-silgen %s -disable-availability-checking
2+
3+
protocol P {
4+
associatedtype A: P
5+
}
6+
7+
struct S: P {
8+
typealias A = S
9+
}
10+
11+
func f<each T: P>(_: repeat each T) -> (repeat each T.A.A.A.A) {}
12+
13+
f(S(), S(), S())

0 commit comments

Comments
 (0)