Skip to content

Commit a208abc

Browse files
committed
RequirementMachine: Desugar requirements in AbstractGenericSignatureRequest
The requirements passed to this request may have been substituted, meaning the subject type might be a concrete type and not a type parameter. Also, the right hand side of conformance requirements here might be a protocol composition. Desugaring converts these kinds of requirements into "proper" requirements where the subject type is always a type parameter, which is what the RuleBuilder expects.
1 parent df8ce67 commit a208abc

File tree

1 file changed

+14
-3
lines changed

1 file changed

+14
-3
lines changed

lib/AST/RequirementMachine/RequirementMachineRequests.cpp

Lines changed: 14 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,7 @@
2626
#include "swift/AST/Requirement.h"
2727
#include "swift/AST/TypeCheckRequests.h"
2828
#include "swift/Basic/Statistic.h"
29+
#include "RequirementLowering.h"
2930
#include <memory>
3031
#include <vector>
3132

@@ -329,9 +330,19 @@ AbstractGenericSignatureRequestRQM::evaluate(
329330
SmallVector<Requirement, 4> requirements(
330331
baseSignature.getRequirements().begin(),
331332
baseSignature.getRequirements().end());
332-
requirements.append(
333-
addedRequirements.begin(),
334-
addedRequirements.end());
333+
334+
// The requirements passed to this request may have been substituted,
335+
// meaning the subject type might be a concrete type and not a type
336+
// parameter.
337+
//
338+
// Also, the right hand side of conformance requirements here might be
339+
// a protocol composition.
340+
//
341+
// Desugaring converts these kinds of requirements into "proper"
342+
// requirements where the subject type is always a type parameter,
343+
// which is what the RuleBuilder expects.
344+
for (auto req : addedRequirements)
345+
desugarRequirement(req, requirements);
335346

336347
// Heap-allocate the requirement machine to save stack space.
337348
std::unique_ptr<RequirementMachine> machine(new RequirementMachine(

0 commit comments

Comments
 (0)