IRGen: Fix silly mistake in MetadataPath::followComponent()

This fixes a regression from a00157ec43.

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.
This commit is contained in:
Slava Pestov
2025-04-09 11:28:15 -04:00
parent be5d03faa3
commit 5a39c81d8a
2 changed files with 34 additions and 6 deletions

View File

@@ -3390,16 +3390,15 @@ MetadataResponse MetadataPath::followComponent(IRGenFunction &IGF,
assert(entry.isOutOfLineBase());
auto inheritedProtocol = entry.getBase();
sourceKey.Kind =
LocalTypeDataKind::forAbstractProtocolWitnessTable(inheritedProtocol);
if (sourceKey.Kind.isConcreteProtocolConformance()) {
auto inheritedConformance =
sourceKey.Kind.getConcreteProtocolConformance()
->getInheritedConformance(inheritedProtocol);
if (inheritedConformance) {
sourceKey.Kind = LocalTypeDataKind::forConcreteProtocolWitnessTable(
inheritedConformance);
}
sourceKey.Kind = LocalTypeDataKind::forConcreteProtocolWitnessTable(
inheritedConformance);
} else {
sourceKey.Kind =
LocalTypeDataKind::forAbstractProtocolWitnessTable(inheritedProtocol);
}
if (!source) return MetadataResponse();

View File

@@ -0,0 +1,29 @@
// RUN: %target-swift-frontend -emit-ir %s
public protocol P1 {
associatedtype A: P3
}
public protocol P2: P1 where A.B == G<C> {
associatedtype C where C == A.B.C
}
public protocol P3 {
associatedtype B: P4
}
public protocol P4: P5 {}
public protocol P5 {
associatedtype C: P6
}
public protocol P6 {
func foo()
}
public struct G<C: P6>: P4 {}
public func f<T: P2>(_: T, c: T.C) {
return c.foo()
}