Skip to content

Commit 1e5ebb3

Browse files
committed
IRGen: Fix silly mistake in MetadataPath::followComponent()
This fixes a regression from a00157e. My change made it so that sourceKey.Kind was checked after being overwritten with an abstract conformance, so we would never take the if statement. Incredibly, it almost worked. Fixes rdar://problem/148698142.
1 parent 69ebffb commit 1e5ebb3

File tree

2 files changed

+34
-6
lines changed

2 files changed

+34
-6
lines changed

lib/IRGen/GenProto.cpp

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -3410,16 +3410,15 @@ MetadataResponse MetadataPath::followComponent(IRGenFunction &IGF,
34103410
assert(entry.isOutOfLineBase());
34113411
auto inheritedProtocol = entry.getBase();
34123412

3413-
sourceKey.Kind =
3414-
LocalTypeDataKind::forAbstractProtocolWitnessTable(inheritedProtocol);
34153413
if (sourceKey.Kind.isConcreteProtocolConformance()) {
34163414
auto inheritedConformance =
34173415
sourceKey.Kind.getConcreteProtocolConformance()
34183416
->getInheritedConformance(inheritedProtocol);
3419-
if (inheritedConformance) {
3420-
sourceKey.Kind = LocalTypeDataKind::forConcreteProtocolWitnessTable(
3421-
inheritedConformance);
3422-
}
3417+
sourceKey.Kind = LocalTypeDataKind::forConcreteProtocolWitnessTable(
3418+
inheritedConformance);
3419+
} else {
3420+
sourceKey.Kind =
3421+
LocalTypeDataKind::forAbstractProtocolWitnessTable(inheritedProtocol);
34233422
}
34243423

34253424
if (!source) return MetadataResponse();
Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
// RUN: %target-swift-frontend -emit-ir %s
2+
3+
public protocol P1 {
4+
associatedtype A: P3
5+
}
6+
7+
public protocol P2: P1 where A.B == G<C> {
8+
associatedtype C where C == A.B.C
9+
}
10+
11+
public protocol P3 {
12+
associatedtype B: P4
13+
}
14+
15+
public protocol P4: P5 {}
16+
17+
public protocol P5 {
18+
associatedtype C: P6
19+
}
20+
21+
public protocol P6 {
22+
func foo()
23+
}
24+
25+
public struct G<C: P6>: P4 {}
26+
27+
public func f<T: P2>(_: T, c: T.C) {
28+
return c.foo()
29+
}

0 commit comments

Comments
 (0)