Skip to content

Commit 25fb866

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 1663b1d commit 25fb866

File tree

2 files changed

+18
-1
lines changed

2 files changed

+18
-1
lines changed

lib/AST/RequirementMachine/RequirementLowering.cpp

+6-1
Original file line numberDiff line numberDiff line change
@@ -976,7 +976,12 @@ TypeAliasRequirementsRequest::evaluate(Evaluator &evaluator,
976976
// to the associated type would have to be conditional, which we cannot
977977
// model.
978978
if (auto ext = dyn_cast<ExtensionDecl>(type->getDeclContext())) {
979-
if (ext->isConstrainedExtension()) continue;
979+
// FIXME: isConstrainedExtension() can cause request cycles because it
980+
// computes a generic signature. getTrailingWhereClause() should be good
981+
// enough for protocol extensions, which cannot specify constraints in
982+
// any other way right now (eg, via requirement inference or by
983+
// extending a bound generic type).
984+
if (ext->getTrailingWhereClause()) continue;
980985
}
981986

982987
// We found something.
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)