Skip to content

Commit 609f436

Browse files
committed
Sema: Fix crash with circular type witness edge case
Fixes #75371
1 parent ca0afe2 commit 609f436

File tree

2 files changed

+22
-1
lines changed

2 files changed

+22
-1
lines changed

lib/Sema/TypeCheckProtocol.cpp

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4683,7 +4683,10 @@ void ConformanceChecker::resolveSingleWitness(ValueDecl *requirement) {
46834683
ReferencedAssociatedTypesRequest{requirement},
46844684
TinyPtrVector<AssociatedTypeDecl *>());
46854685
for (auto assocType : referenced) {
4686-
if (Conformance->getTypeWitness(assocType)->hasError()) {
4686+
auto typeWitness = Conformance->getTypeWitness(assocType);
4687+
if (!typeWitness)
4688+
return;
4689+
if (typeWitness->hasError()) {
46874690
Conformance->setInvalid();
46884691
return;
46894692
}
Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
// RUN: %target-swift-frontend -emit-ir %s
2+
3+
// https://github.com/swiftlang/swift/issues/75371
4+
5+
public protocol MyProtocol {
6+
associatedtype Value = Self
7+
8+
static var originalValue: Value { get }
9+
static var copyValue: Value { get }
10+
}
11+
12+
public struct MyStruct: MyProtocol {}
13+
14+
extension MyStruct {
15+
public static let originalValue = Self()
16+
public static let copyValue = originalValue
17+
}
18+

0 commit comments

Comments
 (0)