Skip to content

Commit a7a38d6

Browse files
committed
GSB: Don't forget to concretize conformances when processing a same-type requirement
When merging two type parameters T1 and T2, if T2 had a concrete type and T1 had conformance requirements, we did not "concretize" the conformances. As a result, the conformance requirements were not marked as redundant, which would cause a crash (no assert build) or assertion failure (in an assert build) later on inside rebuildSignatureWithoutRedundantRequirements(). Fixes rdar://problem/79570734.
1 parent e432296 commit a7a38d6

File tree

2 files changed

+24
-1
lines changed

2 files changed

+24
-1
lines changed

lib/AST/GenericSignatureBuilder.cpp

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2492,7 +2492,7 @@ void DelayedRequirement::dump(llvm::raw_ostream &out) const {
24922492
case Type:
24932493
case Layout:
24942494
out << ": ";
2495-
break;
2495+
break;
24962496

24972497
case SameType:
24982498
out << " == ";
@@ -5013,6 +5013,9 @@ GenericSignatureBuilder::addSameTypeRequirementBetweenTypeParameters(
50135013
equivClass->concreteTypeConstraints.end(),
50145014
equivClass2->concreteTypeConstraints.begin(),
50155015
equivClass2->concreteTypeConstraints.end());
5016+
5017+
for (const auto &conforms : equivClass->conformsTo)
5018+
(void)resolveConcreteConformance(T1, conforms.first);
50165019
}
50175020

50185021
// Make T1 the representative of T2, merging the equivalence classes.

test/Generics/rdar79570734.swift

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
// RUN: %target-typecheck-verify-swift
2+
// RUN: %target-swift-frontend -typecheck -debug-generic-signatures %s 2>&1 | %FileCheck %s
3+
4+
public protocol P1 {
5+
associatedtype A
6+
}
7+
8+
public protocol P2 {}
9+
10+
public struct S1: P1 {
11+
public typealias A = S2
12+
}
13+
14+
public struct S2: P2 {}
15+
16+
// CHECK-LABEL: Generic signature: <X, Y where X : P1, Y : P2, Y == X.A>
17+
public struct G<X: P1, Y: P2> where Y == X.A {}
18+
19+
// CHECK-LABEL: Generic signature: <X, Y where X == S1, Y == S1.A>
20+
public extension G where X == S1 {}

0 commit comments

Comments
 (0)