Skip to content

[Generics] Canonicalization in GenericSignatureBuilder and SubstitutionMap #16806

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 2 commits into from
May 23, 2018

Conversation

DougGregor
Copy link
Member

Address two generics bugs related to canonicalization:

  • GenericSignatureBuilder: Canonicalize types when checking concrete and superclass constraints.
  • SubstitutionMap: Canonicalize non-substitutable replacement types.

Fixes rdar://problem/40428709

…aints.

Concrete and superclass constraints may be written involving type parameters
that are later resolved to concrete types. Perform the substitution to
ensure that type equality within constraint checking accounts for other
same-type constraints.

Fixes assertion in rdar://problem/40428709.
When we compute a replacement type for a non-substitutable generic
parameter, canonicalize the type when our generic signature is
canonical. This ensures that the canonical substitution map will
have canonical types for all of the replacement types… including those
for non-substitutable generic parameters that aren’t part of the
FoldingSet profile.
@DougGregor
Copy link
Member Author

@swift-ci please smoke test and merge

},
[&](const Constraint<Type> &constraint) {
Type concreteType = constraint.value;

// If the concrete type is equivalent, the constraint is redundant.
// FIXME: Should check this constraint after substituting in the
// archetype anchors for each dependent type.
if (concreteType->isEqual(equivClass->concreteType))
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why isn't this comparing to the resolved one?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

EEEP! Nice catch; I'll fix.

@swift-ci swift-ci merged commit 57d74fa into swiftlang:master May 23, 2018
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.

3 participants