Skip to content

Commit 74616db

Browse files
committed
RequirementMachine: Fix concrete conformances with inherited protocols
1 parent 42e2050 commit 74616db

File tree

2 files changed

+20
-1
lines changed

2 files changed

+20
-1
lines changed

lib/AST/RequirementMachine/GeneratingConformances.cpp

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -815,7 +815,12 @@ void GeneratingConformances::computeGeneratingConformances(
815815
bool derivedViaConcrete = false;
816816
for (const auto &path : paths) {
817817
if (path.empty())
818-
break;
818+
continue;
819+
820+
// If the rule is itself a concrete conformance, it is not
821+
// derived-via-concrete via itself.
822+
if (path.size() == 1 && path.front() == ruleID)
823+
continue;
819824

820825
if (System.getRule(path.back()).getLHS().back().getKind() ==
821826
Symbol::Kind::ConcreteConformance) {
Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
// RUN: %target-swift-frontend -typecheck %s -debug-generic-signatures -requirement-machine-protocol-signatures=on 2>&1 | %FileCheck %s
2+
3+
protocol Sequence {}
4+
5+
protocol Collection : Sequence {}
6+
7+
struct MyCollection : Collection {}
8+
9+
// CHECK-LABEL: inherited_concrete_conformance_in_protocol.(file).P@
10+
// CHECK-LABEL: Requirement signature: <Self where Self.T == MyCollection>
11+
12+
protocol P {
13+
associatedtype T : Collection where T == MyCollection
14+
}

0 commit comments

Comments
 (0)