Skip to content

Commit 5a39c81

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 be5d03f commit 5a39c81

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
@@ -3390,16 +3390,15 @@ MetadataResponse MetadataPath::followComponent(IRGenFunction &IGF,
33903390
assert(entry.isOutOfLineBase());
33913391
auto inheritedProtocol = entry.getBase();
33923392

3393-
sourceKey.Kind =
3394-
LocalTypeDataKind::forAbstractProtocolWitnessTable(inheritedProtocol);
33953393
if (sourceKey.Kind.isConcreteProtocolConformance()) {
33963394
auto inheritedConformance =
33973395
sourceKey.Kind.getConcreteProtocolConformance()
33983396
->getInheritedConformance(inheritedProtocol);
3399-
if (inheritedConformance) {
3400-
sourceKey.Kind = LocalTypeDataKind::forConcreteProtocolWitnessTable(
3401-
inheritedConformance);
3402-
}
3397+
sourceKey.Kind = LocalTypeDataKind::forConcreteProtocolWitnessTable(
3398+
inheritedConformance);
3399+
} else {
3400+
sourceKey.Kind =
3401+
LocalTypeDataKind::forAbstractProtocolWitnessTable(inheritedProtocol);
34033402
}
34043403

34053404
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)