Commit Graph

845 Commits

Author SHA1 Message Date
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
Slava Pestov
75dfab00b9 RequirementMachine: Eliminate layout requirement implied by concrete type requirement
A type parameter subject to an AnyObject requirement might also be subject
to a concrete type requirement. There are two cases to handle here:

- If the concrete type is a class, the layout requirement is redundant.
- If the concrete type is not a class, we have a conflict.

There is an existing test that's good enough; I just changed it to
run with -requirement-machine-inferred-signatures=verify.
2022-01-25 00:35:11 -05:00
Slava Pestov
41e3292015 RequirementMachine: Remove 'induced rules' mechanism from the property map 2022-01-25 00:35:11 -05:00
Slava Pestov
0b3d6ea028 RequirementMachine: Property map adds new rules directly 2022-01-25 00:35:11 -05:00
Slava Pestov
ae44028117 RequirementMachine: Allow the property map to record induced rules directly
It doesn't actually do this yet, but the idea is to look at the
total rule count before and after, instead of just looking at the
induced rules array (which I will delete in the next commit).
2022-01-25 00:35:11 -05:00
Slava Pestov
10e4ffdfbd RequirementMachine: Track known protocols in the rewrite system
Conditional requirement inference needs to be able to add rewrite rules
from the requirement signatures of hitherto-unseen protocols, so to
help with that, extract out the RuleBuilder's ProtocolMap and move it
into the RewriteSystem.
2022-01-25 00:35:03 -05:00
Slava Pestov
96122834fb RequirementMachine: getRuleForRequirement() supports relative terms 2022-01-25 00:32:25 -05:00
Slava Pestov
c46c7773ed RequirementMachine: Rename remapConcreteSubstitutionSchema() to getRelativeSubstitutionSchemaFromType() 2022-01-25 00:32:25 -05:00
Slava Pestov
01ba790ccf RequirementMachine: Move remapConcreteSubstitutionSchema() to RewriteContext 2022-01-25 00:32:25 -05:00
Slava Pestov
b27c15686c RequirementMachine: Add assertion to RewriteSystem::isInMinimizationDomain() 2022-01-25 00:32:25 -05:00
Slava Pestov
f480eeaf53 RequirementMachine: Factor out getRuleForRequirement() from RuleBuilder::addRequirement() 2022-01-25 00:32:25 -05:00
Slava Pestov
f3b8bedf1f RequirementMachine: Fix assertion failure when conflicting rules are also redundant
We can end up with two redundant concrete type rules on the same
term, but we would crash in homotopy reduction because the rules
were incomparable due to the concrete type symbol at the end.

If one of them is conflicting though, we don't really care about
the homotopy reduction order, so skip the check if the other
rule was already marked conflicting.
2022-01-25 00:32:25 -05:00
Slava Pestov
7a5758ea43 RequirementMachine: Fix missing space in debug output 2022-01-25 00:32:25 -05:00
Slava Pestov
a2f2ffd1c2 RequirementMachine: Remove obsolete comment 2022-01-25 00:32:25 -05:00
Slava Pestov
275af8d0fd RequirementMachine: getTypeForSymbolRange() maps canonical terms to canonical types
Previously this would only be true with merged associated types,
but I want to get rid of those.
2022-01-20 14:18:25 -05:00
Slava Pestov
8468c14dbc RequirementMachine: Add overload of PropertyMap::lookUpProperties() that takes a pair of iterators 2022-01-20 12:48:48 -05:00
Slava Pestov
fa30159130 RequirementMachine: Move term to type methods from RewriteContext to PropertyMap 2022-01-20 00:18:47 -05:00
Slava Pestov
86f17a71e2 RequirementMachine: Move term to type conversion to a new file InterfaceType.cpp 2022-01-19 23:43:48 -05:00
Slava Pestov
0ffd11c558 RequirementMachine: New GenericSignature::isValidTypeInContext() query 2022-01-14 21:25:32 -08:00
Slava Pestov
da30258f49 RequirementMachine: Remove RewriteSystem::TypeWitness 2022-01-13 19:14:52 -05:00
Slava Pestov
bdbf50e1e3 RequirementMachine: Replace RewriteStep::SameTypeWitness with a relation 2022-01-13 19:14:52 -05:00
Slava Pestov
6064671abd RequirementMachine: Replace RewriteStep::ConcreteTypeWitness with relations 2022-01-13 18:01:15 -05:00
Slava Pestov
84e2a627ec RequirementMachine: Replace RewriteStep::AbstractTypeWitness with relations 2022-01-13 00:02:31 -05:00
Slava Pestov
abb85fb3ca RequirementMachine: Replace RewriteStep::{Superclass,Concrete}Conformance with relations 2022-01-13 00:02:31 -05:00
Slava Pestov
3d2492fe56 RequirementMachine: Rename RewriteStep::ApplyRewriteRule to RewriteStep::Rule 2022-01-13 00:02:31 -05:00
Slava Pestov
f06f59a18a RequirementMachine: Generalize relations so they look more like rules 2022-01-13 00:02:31 -05:00
Slava Pestov
220d4882fd RequirementMachine: Move some code to a new PropertyRelations.cpp file 2022-01-13 00:02:31 -05:00
Slava Pestov
a7091d9b0d RequirementMachine: Fix terminology in debug message 2022-01-13 00:02:31 -05:00
Slava Pestov
f674ca95bd RequirementMachine: Remove the older 'concrete type in domain' hack 2022-01-11 21:43:56 -05:00