Commit Graph

20 Commits

Author SHA1 Message Date
Slava Pestov
86c15ad5c1 RequirementMachine: Generating conformances can reason about concrete conformances now 2021-12-08 00:53:35 -05:00
Slava Pestov
34cbfd23a5 RequirementMachine: Don't assert if a rewrite system has unresolved rules
This is a source-level error, not an invariant violation. Instead, plumb
a new hadError() flag, which in the future will assert if no diagnostic
was produced.
2021-12-08 00:53:34 -05:00
Slava Pestov
d19b15b66c RequirementMachine: Introduce Symbol::Kind::ConcreteConformance 2021-12-06 23:04:46 -05:00
Slava Pestov
291ddd7a31 RequirementMachine: Plumb through the ModuleDecl used for requirement inference 2021-11-29 13:54:15 -05:00
Slava Pestov
af9ea678ed RequirementMachine: Implement InferredGenericSignatureRequest 2021-11-19 17:06:00 -05:00
Slava Pestov
a208abc54c 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.
2021-11-12 14:30:46 -05:00
Slava Pestov
2666449aa6 RequirementMachine: Implement AbstractGenericSignatureRequestRQM 2021-11-12 00:32:43 -05:00
Slava Pestov
24bdecdca5 AST: Remove ASTContext::getOrCreateRequirementMachine() in favor of getRewriteContext() 2021-11-11 22:39:20 -05:00
Slava Pestov
952dafad72 RequirementMachine: Preliminary refactoring in preparation for computing top-level generic signatures 2021-11-11 22:39:20 -05:00
Slava Pestov
2c4cfdcb1f RequirementMachine: Generating conformances prefers to delete non-explicit rules
This is a heuristic to ensure that conformance requirements remain in
their original protocol if possible, when the protocol is part of a
connected component consisting of multiple protocols.
2021-11-10 00:18:57 -05:00
Slava Pestov
b30aa22f73 RequirementMachine: Split off RequirementSignatureRequestRQM from RequirementSignatureRequest
This is a refactoring needed to implement 'verify' mode. The
RequirementMachine computes the requirement signature for an
entire connected component of protocols at once, whereas the
GenericSignatureBuilder only does one protocol at a time.

Using the same request for both in 'verify' mode meant that
we would only call the GSB for the first protocol in a
connected component, and then the RequirementMachine would
fill in the rest.

To fix this, split it up into two requests. The original
RequirementSignatureRequest calls into the GSB, and then
kicks off a RequirementSignatureRequestRQM to get the
requirement signature computed by the RequirementMachine
(possibly cached, if this protocol is part of a connected
component with more than one protocol in it).
2021-11-01 22:51:59 -04:00
Slava Pestov
0d167a435c AST: Move GenericSignatureBuilder.h from include/swift/AST/ to lib/AST/ 2021-10-30 00:35:59 -04:00
Slava Pestov
f44926b6b9 RequirementMachine: Tighten up createRequirementFromRule()
Now that the 'identity conformance' [P].[P] => [P] is permanent,
we won't see it here, so we can just assume that any non-permanent,
non-redundant rule maps to a requirement.
2021-10-27 00:38:42 -04:00
Slava Pestov
74d944d511 RequirementMachine: Use llvm::array_pod_sort() to sort requirements 2021-10-27 00:38:26 -04:00
Slava Pestov
0571b65cb8 RequirementMachine: Move protocol linear order from ProtocolGraph to RewriteContext 2021-10-21 19:00:10 -04:00
Slava Pestov
cd8692466d RequirementMachine: Better simulation of GSB's 'connected components' malarkey 2021-10-15 15:13:22 -04:00
Slava Pestov
25718c7d8f RequirementMachine: Preliminary support for minimizing layout, superclass and concrete type requirements 2021-10-14 15:03:28 -04:00
Slava Pestov
85dfbcdedb RequirementMachine: Move some code from RequirementMachine.cpp to RequirementMachineRequests.cpp 2021-10-09 19:11:14 -04:00
Slava Pestov
7244102b4d RequirementMachine: Wire up protocol requirement signature minimization 2021-10-09 19:11:14 -04:00
Slava Pestov
14708adf5c RequirementMachine: Move implementation of RequirementSignatureRequest out of Sema
For now, this still uses the GSB.
2021-10-08 14:28:27 -04:00