Skip to content

GSB: Introduce a list of explicit as-written requirements #36577

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
Mar 25, 2021

Conversation

slavapestov
Copy link
Contributor

Store the original explicit requirements (written by the user or inferred from concrete type constructors). This will eventually be used to simplify the code for forming the minimized signature, diagnosing redundant and conflicting requirements, and rebuilding a signature after dropping requirements.

…eConcreteType()

Type::subst() does not support DependentMemberTypes that only have
an identifier and not an associated type. Instead, when we hit one
of these, replace the generic parameter at the root with its
replacement type only, then rely on maybeResolveEquivalenceClass()
getting called again, which will perform the name lookup to resolve
the member type.
We would invalidate the cache if the superclass changed, but
not the concrete type. Let's do the same with the concrete
type.

This fixes one small part of rdar://problem/75656022.
…alTypeInContext()

For now this has no effect since resolveDependentMemberTypes() maps
type parameters to anchors, but I'm going to change it to not do
that.

Change all existing callers of resolveDependentMemberTypes() except
for the one in maybeResolveEquivalenceClass() to use
getCanonicalTypeInContext() instead.
When a concrete type contains unresolved DependentMemberTypes, we
don't need to replace them with their anchor, just the resolved
representative from the PotentialArchetype.

This means that the only time we compute anchors are when
computing canonical types (which is only done after a GSB has
been finalized) and when adding same-type requirements.

This should eventually enable building the same-type rewrite
system in one shot.
This will allow us to rebuild the generic signature using the
as-written requirements, instead of the previously-minimized
signature.
Extract out createRequirement(), since I'm going to be using it soon.

Also, merge the two loops together to do a single walk over all the
equivalence classes, instead of pointlessly building a list of
SameTypeComponentRefs first.
I want to use the same predicate for sorting requirements as what
we use to assert that the signature was valid.
@slavapestov
Copy link
Contributor Author

@swift-ci Please smoke test

@slavapestov
Copy link
Contributor Author

@swift-ci Please test source compatibility

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