Skip to content

Conversation

@slavapestov
Copy link
Contributor

@slavapestov slavapestov commented Jan 17, 2024

Follow-up to #70937 and #70951.

To check if a substitution map satisfies a generic signature (for example, when resolving a generic type representation, or checking a conditional conformance) we apply a substitution map to each requirement to get a substituted requirement, then check if the substituted requirement is satisfied.

A substituted requirement is a statement about concrete types, so if a substituted requirement still contains type parameters we cannot answer questions about it, because we don't have a generic signature. For example, if T is a type parameter, [Array<T>: Equatable] cannot be answered one way or another, because we don't know if T: Equatable.

Clients should only check requirements against a substitution map whose replacement types are fully concrete, or contain archetypes. If T is an archetype, then [Array<T>: Equatable] can be decided by checking if T conforms to Equatable.

Formerly, checkRequirements() would silently return false if any requirements contained type parameters. Now, it asserts.

Note that most of the diff is a separate commit splitting off ConformanceLookup.cpp from Module.cpp.

@slavapestov slavapestov force-pushed the check-requirement-invariant branch 2 times, most recently from 49821aa to 6f3bde5 Compare January 18, 2024 02:11
@slavapestov slavapestov force-pushed the check-requirement-invariant branch from 6f3bde5 to 6fd1602 Compare January 18, 2024 02:17
@slavapestov slavapestov changed the title Enforce that we only see substituted requirements in checkRequirement() Enforce that we only see substituted requirements in checkRequirements() Jan 18, 2024
@slavapestov slavapestov force-pushed the check-requirement-invariant branch from 6fd1602 to 6adab3c Compare January 18, 2024 17:32
@slavapestov
Copy link
Contributor Author

@swift-ci Please smoke test

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