Skip to content

RequirementMachine: Introduce 'concrete contraction' pre-processing pass before building rewrite system #41554

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 3 commits into from
Feb 25, 2022

Conversation

slavapestov
Copy link
Contributor

See the comment at the top of ConcreteContraction.cpp for a detailed explanation.

Fixes rdar://problem/88135912.

…er superclass requirements again

If you have something like this:

    protocol P {
      associatedtype A : Q where Self == Self.A.B
    }

    protocol Q {
      associatedtype B
    }

    class C : P {
      typealias A = D
    }

    class D : P {
      typealias B = C
    }

The GSB would minimize the generic signature <T where T : P, T : C>
to <T where T == C>, because of the same-type requirement in
protocol P.

However in reality, the conformance 'C : P' is unsound, because it
is no longer covariant. I added a warning in commit d831eff74879cb.

Because the upcoming 'concrete contraction' pass eliminates 'T : P'
before homotopy reduction gets a chance to run, I'm changing the
Requirement Machine to produce a different minimization from the
GSB. This is technically an ABI break, but it should not impact any
real code in practice. If it does, I'll need to come up with a
different workaround in concrete contraction.
…o a non-conforming type

The conflicting rule here is the permanent 'identity conformance'
([P].[P] => [P]). Permanent rules cannot be marked as conflicting,
so just check for this condition first.
…ass before building rewrite system

See the comment at the top of ConcreteContraction.cpp for a detailed explanation.

This can be turned off with the -disable-requirement-machine-concrete-contraction
pass, mostly meant for testing. A few tests now run with this pass both enabled
and disabled, to exercise code paths which are otherwise trivially avoided by
concrete contraction.

Fixes rdar://problem/88135912.
@slavapestov slavapestov force-pushed the rqm-concrete-contraction branch from fef249d to 8e09ba8 Compare February 25, 2022 16:48
@slavapestov
Copy link
Contributor Author

@swift-ci Please smoke test

@slavapestov slavapestov merged commit a5a15ba into swiftlang:main Feb 25, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant