Skip to content

RequirementMachine: Implement minimization for concrete nested type requirements #40543

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 9 commits into from
Dec 14, 2021

Conversation

slavapestov
Copy link
Contributor

@slavapestov slavapestov commented Dec 14, 2021

Consider the following protocol:

protocol P {
  associatedtype T : Sequence where T == Array<Int>
}

The requirements T : Sequence and T == Array<Int> together imply that T.Element == Int. When property map construction adds this rule while walking nested types of conformances, we now record a rewrite path that relates this rule with the concrete conformance rule. This allows the nested type rules to be dropped from the minimized signature.

There are other cases where the property map still records new rules without a rewrite path. For now, these rules are never minimized away. The goal is to never do this; eventually we will assert that new rules recorded after completion always have a rewrite path relating them to existing rules.

… the GSB got it wrong

These fail with -requirement-machine-protocol-signatures=verify because
the GSB produces incorrect output. Enable the requirement machine
unconditionally for these tests, bypassing verification.

A new file test/Generics/same_type_requirements_in_protocol.swift
contains reduced versions of all of the failures, with FileCheck
used to confirm the exact requirement signature output.
@slavapestov slavapestov force-pushed the rqm-type-witness-minimization branch from 922c46c to 2441e68 Compare December 14, 2021 07:18
@slavapestov slavapestov marked this pull request as ready for review December 14, 2021 07:25
@slavapestov
Copy link
Contributor Author

@swift-ci Please test source compatibility

@slavapestov
Copy link
Contributor Author

@swift-ci Please smoke test

@slavapestov
Copy link
Contributor Author

@swift-ci Please smoke test macOS

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