Skip to content

Commit b0b4a64

Browse files
authored
Merge pull request #80676 from slavapestov/fix-rdar148698142-6.2
[6.2] IRGen: Fix silly mistake in MetadataPath::followComponent()
2 parents 5730559 + cca31be commit b0b4a64

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
@@ -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();

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)