Commit Graph

873 Commits

Author SHA1 Message Date
Slava Pestov
0d0bcb2ff1 RequirementMachine: Simplify the Symbol API for removal of merged associated types 2022-02-07 18:57:45 -05:00
Slava Pestov
e2e088e082 RequirementMachine: Remove merged associated types from completion 2022-02-07 18:57:45 -05:00
Slava Pestov
868e48cb7a RequirementMachine: Mark rules as simplified in PropertyMap::addConcreteTypeProperty() 2022-02-07 08:20:59 -05:00
Slava Pestov
9e234a09c6 RequirementMachine: Record rewrite loop relating concrete type rules in processTypeDifference()
We can't actually rely on concretelySimplifyLeftHandSideSubstitutions()
to do this for us, because the less-simplified rule (the LHS rule)
might only apply to a suffix of the base term.
2022-02-07 08:20:59 -05:00
Slava Pestov
5bb80286e9 RequirementMachine: Factor out a utility for building a rewrite path unifying to concrete type rules 2022-02-07 08:20:59 -05:00
Slava Pestov
70876171e6 RequirementMachine: Build rewrite paths for concrete unification induced rules 2022-02-07 08:20:59 -05:00
Slava Pestov
9ee702026f RequirementMachine: Factor out TypeDifference::getOriginalSubstitution() 2022-02-07 08:20:59 -05:00
Slava Pestov
60db9174e6 RequirementMachine: Factor out PropertyMap::processTypeDifference() 2022-02-07 08:20:59 -05:00
Slava Pestov
fcd467ad4c RequirementMachine: Factor out TypeDifference::getReplacementSubstitution() 2022-02-07 08:20:59 -05:00
Slava Pestov
2c355de71b RequirementMachine: Introduce RewriteStep::{Left,Right}ConcreteProjection 2022-02-07 08:20:59 -05:00
Slava Pestov
00d226fd2f RequirementMachine: Store the base term in the TypeDifference 2022-02-07 08:20:59 -05:00
Slava Pestov
06d4770adb RequirementMachine: Teach homotopy reduction to better deal with incomparable rules 2022-02-07 08:20:59 -05:00
Slava Pestov
037dc98845 RequirementMachine: Generalize compare() methods to return None instead of asserting on incomparable symbols 2022-02-07 08:20:59 -05:00
Slava Pestov
37be2d5dd7 RequirementMachine: Emit a diagnostic note with the offending rewrite rule if completion failed
This surfaces an implementation detail, but it might be better
than nothing.
2022-02-07 08:20:59 -05:00
Slava Pestov
b0dd114fdd RequirementMachine: Add a FIXME comment 2022-02-07 08:20:59 -05:00
Slava Pestov
0060592b85 RequirementMachine: Add concrete nesting depth check
Configured with -requirement-machine-max-concrete-nesting= frontend flag.
2022-02-07 08:20:59 -05:00
Slava Pestov
634ca55764 RequirementMachine: Rework completion limits a bit
- Rename StepLimit to MaxRuleCount, DepthLimit to MaxRuleLength
- Rename command line flags to -requirement-machine-max-rule-{count,length}=
- Check limits outside of PropertyMap::buildPropertyMap()
- Simplify the logic in RequirementMachine::computeCompletion()
2022-02-07 08:20:59 -05:00
Slava Pestov
730941b3ea RequirementMachine: Implement PropertyMap::concretelySimplifyLeftHandSideSubstitutions() 2022-02-07 08:20:58 -05:00
Slava Pestov
7e4a5876d1 RequirementMachine: Introduce RewriteStep::DecomposeConcrete 2022-02-07 08:20:58 -05:00
Slava Pestov
d8aa79c5e5 RequirementMachine: Rename RewriteStep::AdjustConcreteType to ::PrefixSubstitutions 2022-02-07 08:20:58 -05:00
Slava Pestov
7464a5f139 RequirementMachine: Make recordTypeDifference() and buildTypeDifference() public 2022-02-07 08:20:58 -05:00
Slava Pestov
73296edc63 RequirementMachine: Less indirect TypeDifference representation 2022-02-07 08:20:58 -05:00
Slava Pestov
e19ee4d1a1 RequirementMachine: Refactor PropertyMap::addConcreteTypeProperty() to use computeTypeDifference()
This doesn't record rewrite loops from most concrete unifications just yet,
only handling a case where two concrete types were identical except for an
adjustment.
2022-02-07 08:20:58 -05:00
Slava Pestov
8eb8e8d86d RequirementMachine: Make RewriteSystem::recordRewriteLoop() public for use by the property map 2022-02-07 08:20:58 -05:00
Slava Pestov
b28d35fa22 RequirementMachine: Introduce RewriteSystem::computeTypeDifference() 2022-02-07 08:20:58 -05:00
Slava Pestov
0c777e7534 RequirementMachine: Split up PropertyMap::addProperty() 2022-02-07 08:20:58 -05:00
Slava Pestov
a11151a7e3 RequirementMachine: Fix up some comments 2022-02-04 22:49:28 -05:00
Slava Pestov
3790bba7a0 RequirementMachine: Verify loops immediately when they're added to aid debugging 2022-02-04 22:48:35 -05:00
Slava Pestov
6895fa0f9b RequirementMachine: Remove dead RewriteStep::applyConcreteConformance() declaration 2022-02-04 22:48:05 -05:00
Slava Pestov
e12cdd3773 RequirementMachine: Split off nested type concretization from PropertyUnification.cpp to ConcreteTypeWitness.cpp 2022-02-04 22:47:49 -05:00
Slava Pestov
b138c7602d RequirementMachine: Add DebugFlags::PropertyMap 2022-02-04 22:47:49 -05:00
Slava Pestov
4f3d05f502 RequirementMachine: Remove Symbol::getSuperclass() 2022-02-04 22:47:19 -05:00
Slava Pestov
1539128dc4 RequirementMachine: Move getGenericParamIndex() to RewriteContext 2022-02-04 22:47:19 -05:00
Slava Pestov
8b99812f15 RequirementMachine: Stricter RewriteSystem::verifyRewriteRules() 2022-02-04 22:47:19 -05:00
Slava Pestov
8df7ca01fd RequirementMachine: Remove useless assertion from MinimalConformances::collectConformanceRules()
We rule out RHS-simplified rules immediately above.
2022-02-04 22:47:19 -05:00
Slava Pestov
0177f75473 AST: TypeBase::isConstraintType() answers true for ParameterizedProtocolType also 2022-02-03 13:27:24 -05:00
Slava Pestov
aa67c8bf8a Parametrized => parameterized 2022-02-03 13:27:24 -05:00
Slava Pestov
8e94fff3d4 RequirementMachine: Fix up concrete conformance handling in minimal conformances algorithm 2022-01-27 18:54:03 -05:00
Slava Pestov
04f9bce79a RequirementMachine: Treat LHS-simplified and RHS-simplified/substitution-simplified rules separately in minimization 2022-01-27 18:54:03 -05:00
Slava Pestov
aab4e4325c RequirementMachine: The three RewriteSystem::simplify*() methods check flags independently
We used to skip a pass if any of the three flags were set, but we have
to check them separately to ensure that all flags are independently
set correctly.
2022-01-27 18:54:03 -05:00
Slava Pestov
106896228e RequirementMachine: Split up Rule::isSimplified() into three predicates
We have three simplification passes, give each one its own predicate:
- Left hand side simplification
- Right hand side simplification
- Substitution simplification

This is for debugging output and will also allow me to tighten up
some invariants.
2022-01-27 18:54:03 -05:00
Slava Pestov
d70945a31a RequirementMachine: Tighten up RewriteSystem::verifyRewriteRules() 2022-01-27 18:54:03 -05:00
Slava Pestov
ad9c701152 RequirementMachine: Don't record useless minimal conformance equations 2022-01-27 18:54:03 -05:00
Slava Pestov
75dfc8b3a8 RequirementMachine: Minimal conformances algorithm ignores conformance rules not in our minimization domain 2022-01-27 18:54:03 -05:00
Slava Pestov
1c1b0e6cfc RequirementMachine: Clean up computeCriticalPair() a bit 2022-01-27 18:54:03 -05:00
Slava Pestov
073bb7542e RequirementMachine: Fixes for debug output 2022-01-27 18:54:03 -05:00
Slava Pestov
7dc36c3092 Merge pull request #40714 from slavapestov/parametrized-protocol-type
Parametrized protocol types
2022-01-26 11:44:29 -05:00
Slava Pestov
a416116094 RequirementMachine: Desugar ParametrizedProtocolType 2022-01-26 00:11:38 -05:00
Slava Pestov
7393c9c84f RequirementMachine: Remove unsound cycle-breaking hack 2022-01-25 21:28:52 -05:00
Slava Pestov
eb9f12109e RequirementMachine: Conditional requirement inference
If a type parameter is subject to both a conformance requirement
and a concrete type requirement, the concrete type might conform
conditionally.

In this case, introduce new requirements to satisfy the conditional
conformance.

Since this can add new hitherto-unseen protocols to the rewrite
system, restrict this feature to top-level generic signatures, and
not protocol requirement signatures. Allowing this to occur in
protocol requirement signatures would change the connectivity of
the protocol dependency graph (and hence the connected components)
during completion, which would be a major complication in the
design. The GSB already enforces this restriction.

I changed the existing conditional_requirement_inference.swift test
to run with -requirement-machine-inferred-signatures=verify. Since
one of the test cases there triggers an unrelated bug in the
Requirement Machine, I split it off into a new file named
conditional_requirement_inference_2.swift which still runs with
the GSB. Once the bug is fixed I'll merge the files again.
2022-01-25 00:35:16 -05:00