Skip to content

Commit 5d94a32

Browse files
authored
Merge pull request #80675 from slavapestov/fix-rdar148698142
IRGen: Fix silly mistake in MetadataPath::followComponent()
2 parents 0ae0528 + 6fd0c24 commit 5d94a32

File tree

3 files changed

+37
-9
lines changed

3 files changed

+37
-9
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();

lib/IRGen/LocalTypeDataKind.h

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -117,19 +117,19 @@ class LocalTypeDataKind {
117117
/// same function.
118118
static LocalTypeDataKind
119119
forAbstractProtocolWitnessTable(ProtocolDecl *protocol) {
120-
assert(protocol && "protocol reference may not be null");
120+
ASSERT(protocol && "protocol reference may not be null");
121121
return LocalTypeDataKind(uintptr_t(protocol) | Kind_Decl);
122122
}
123123

124124
/// A reference to a protocol witness table for a concrete type.
125125
static LocalTypeDataKind
126126
forConcreteProtocolWitnessTable(ProtocolConformance *conformance) {
127-
assert(conformance && "conformance reference may not be null");
127+
ASSERT(conformance && "conformance reference may not be null");
128128
return LocalTypeDataKind(uintptr_t(conformance) | Kind_Conformance);
129129
}
130130

131131
static LocalTypeDataKind forProtocolWitnessTablePack(PackConformance *pack) {
132-
assert(pack && "pack conformance reference may not be null");
132+
ASSERT(pack && "pack conformance reference may not be null");
133133
return LocalTypeDataKind(uintptr_t(pack) | Kind_PackConformance);
134134
}
135135

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)