Commit Graph

3 Commits

Author SHA1 Message Date
Slava Pestov
dac8d666ee Stop passing -requirement-machine-{abstract,inferred,protocol}-signatures flags in tests
These flags are now no-ops.
2022-05-10 12:56:17 -04:00
Slava Pestov
5281426569 RequirementMachine: Fix minimization when protocol is constrained to a class that conforms to the protocol
Consider this example:

    protocol P : C {}
    class C : P {}

    <T where T : P>

The GenericSignatureBuilder thinks the minimized signature is
<T where T : P>. The RequirementMachine would minimize it down to
<T where T : C>. The latter is more correct, since the conformance
here is concrete and no witness table needs to be passed in at
runtime, however for strict binary compatibility we need to produce
the same signature as the GenericSignatureBuilder.

Accomplish this by changing the minimal conformances algorithm to
detect "circular concrete conformance rules", which take the form

    [P].[concrete: C : Q]

Where Q : P. These rules are given special handling. Ordinarily a
protocol conformance rule is eliminated before a concrete conformance
rule; however concrete conformances derived from circular
conformances are considered to be redundant from the get-go,
preventing protocol conformances that can be written in terms of
such concrete conformances from themselves becoming redundant.

Fixes rdar://problem/89633532.
2022-03-02 03:13:41 -05:00
Slava Pestov
8f992f0772 AST: Handle concrete superclass conformance when forming forwarding substitutions
Consider this protocol and generic signature:

    class C {}
    protocol P : C {}

    <T where T : P>

Normally the forwarding substitution map for the generic environment
looks like this:

    - T := <<archetype for T>>
    _ T : P := <<abstract conformance to P>>

However, if the class itself conforms to P, ie

    class C : P {}

Then the conformance T : P must be the concrete conformance. Handle
this properly in MakeAbstractConformanceForGenericType.
2022-01-20 20:49:07 -05:00