Skip to content

Commit bdc760c

Browse files
committed
RequirementMachine: Fix a request cycle
RequirementSignatureRequest => TypeAliasRequirementsRequest => isConstrainedExtension() => GenericSignatureRequest => RequirementSignatureRequest Instead, use getTrailingWhereClause() as an approximation of isConstrainedExtension(). Fixes rdar://problem/97236936.
1 parent ae505e5 commit bdc760c

File tree

2 files changed

+18
-1
lines changed

2 files changed

+18
-1
lines changed

lib/AST/RequirementMachine/RequirementLowering.cpp

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -987,7 +987,12 @@ TypeAliasRequirementsRequest::evaluate(Evaluator &evaluator,
987987
// to the associated type would have to be conditional, which we cannot
988988
// model.
989989
if (auto ext = dyn_cast<ExtensionDecl>(type->getDeclContext())) {
990-
if (ext->isConstrainedExtension()) continue;
990+
// FIXME: isConstrainedExtension() can cause request cycles because it
991+
// computes a generic signature. getTrailingWhereClause() should be good
992+
// enough for protocol extensions, which cannot specify constraints in
993+
// any other way right now (eg, via requirement inference or by
994+
// extending a bound generic type).
995+
if (ext->getTrailingWhereClause()) continue;
991996
}
992997

993998
// We found something.
Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
// RUN: %target-typecheck-verify-swift
2+
3+
protocol P {
4+
associatedtype A
5+
associatedtype B
6+
}
7+
8+
protocol Q: P {}
9+
10+
extension Q where A == Int {
11+
typealias B = Int
12+
}

0 commit comments

Comments
 (0)