Commit Graph

117 Commits

Author SHA1 Message Date
Slava Pestov
060f490983 RequirementMachine: Implement GenericSignature::getSuperclassBound() query 2021-07-14 00:15:42 -04:00
Slava Pestov
e36b95d620 RequirementMachine: Split up list of associated types in ProtocolGraph
Store the protocol's direct associated types separately from the inherited
associated types, since in a couple of places we only need the direct
associated types.

Also, factor out a new ProtocolGraph::compute() method that does all the
steps in the right order.
2021-07-14 00:11:37 -04:00
Slava Pestov
9a0c87b196 RequirementMachine: Implement GenericSignature::getCanonicalTypeInContext() query
We compute the canonical type by first simplifying the type term, and
then checking if it is a concrete type. If there's no concrete type,
we convert the simplified term back to an interface type and return
that; otherwise, we canonicalize any structural sub-components of
the concrete type that contain interface types, and so on.

Due to a quirk of how the existing declaration checker works, we also
need to handle "purely concrete" member types, eg if I have a
signature `<T where T == Foo>`, and we're asked to canonicalize the
type `T.[P:A]` where Foo : A.

This comes up because we can derive the signature `<T where T == Foo>`
from a generic signature like `<T where T : P>`; adding the
concrete requirement 'T == Foo' renders 'T : P' redundant. We then
want to take interface types written against the original signature
and canonicalize them with respect to the derived signature.

The problem is that `T.[P:A]` is not a valid term in the rewrite system
for `<T where T == Foo>`, since we do not have the requirement T : P.

A more principled solution would build a substitution map when
building a derived generic signature that adds new requirements;
interface types would first be substituted before being canonicalized
in the new signature.

For now, we handle this with a two-step process; we split a term up
into a longest valid prefix, which must resolve to a concrete type,
and the remaining suffix, which we use to perform a concrete
substitution using subst().
2021-07-09 00:04:36 -04:00
Slava Pestov
658e1f2707 RequirementMachine: Verify simplified type terms in asserts builds 2021-07-08 23:31:53 -04:00
Slava Pestov
e8eab411ba RequirementMachine: Store the current generic signature 2021-07-08 23:31:53 -04:00
Slava Pestov
56700983de RequirementMachine: Completion step and depth limits also apply to equivalence class map 2021-07-08 23:31:53 -04:00
Slava Pestov
05b3f79cec RequirementMachine: Implement GenericSignature::getRequiredProtocols() query 2021-06-30 01:34:20 -04:00
Slava Pestov
a37ad9fc89 RequirementMachine: Implement GenericSignature::areSameTypeParametersInContext() query 2021-06-30 01:34:20 -04:00
Slava Pestov
5d91b59e87 RequirementMachine: Implement GenericSignature::isConcreteType() query 2021-06-30 01:34:20 -04:00
Slava Pestov
62e0ad0f02 RequirementMachine: Add a dump() method 2021-06-30 01:34:20 -04:00
Slava Pestov
53d68144f8 RequirementMachine: Implement GenericSignature::getLayoutConstraint() query 2021-06-30 01:34:20 -04:00
Slava Pestov
8053b91c0e RequirementMachine: Implement GenericSignature::requiresProtocol() query 2021-06-30 01:34:20 -04:00
Slava Pestov
7df09f14ee RequirementMachine: Implement GenericSignature::requiresClass() query 2021-06-30 01:34:20 -04:00
Slava Pestov
f28d9b3dbf RequirementMachine: Stub out the equivalence class map 2021-06-30 01:34:20 -04:00
Slava Pestov
3418f47939 RequirementMachine: Actually compute the inherited protocol transitive closure 2021-06-30 01:34:07 -04:00
Slava Pestov
40e3409f89 RequirementMachine: Tiny comment fix 2021-06-29 13:09:11 -04:00
Slava Pestov
6c164f682e RequirementMachine: Move files to a new subdirectory under lib/AST/
Also move a all headers other than RequirementMachine.h there, since
I don't expect they will be used outside of the rewrite system
implementation itself.
2021-06-25 00:04:09 -04:00