Skip to content

Commit 8bcd8a3

Browse files
authored
Merge pull request #32424 from slavapestov/silly-assoc-type-default-cycle
Sema: Relax associated type default circularity check
2 parents 34b560f + 8305d51 commit 8bcd8a3

File tree

2 files changed

+8
-1
lines changed

2 files changed

+8
-1
lines changed

lib/Sema/TypeCheckDeclPrimary.cpp

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1730,7 +1730,8 @@ class DeclChecker : public DeclVisitor<DeclChecker> {
17301730
auto mentionsItself =
17311731
defaultType.findIf([&](Type defaultType) {
17321732
if (auto DMT = defaultType->getAs<DependentMemberType>()) {
1733-
return DMT->getAssocType() == AT;
1733+
return (DMT->getAssocType() == AT &&
1734+
DMT->getBase()->isEqual(proto->getSelfInterfaceType()));
17341735
}
17351736
return false;
17361737
});

test/decl/protocol/req/associated_type_default.swift

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -34,3 +34,9 @@ protocol P4 {
3434
}
3535

3636
struct X4 : P4 {} // expected-error{{type 'X4' does not conform to protocol 'P4'}}
37+
38+
// rdar://62355224 - circularity check for default type was over-eager
39+
protocol Seq {
40+
associatedtype SubSeq: Seq
41+
associatedtype Index = SubSeq.Index
42+
}

0 commit comments

Comments
 (0)