[GSB] Push potential archetype realization slightly deeper.
Same-type constraints are (still) described in terms of potential
archetypes, so push the "realization" operation for potential
archetypes down into the function that adds a same-type constraint
between type parameters.
diff --git a/include/swift/AST/GenericSignatureBuilder.h b/include/swift/AST/GenericSignatureBuilder.h
index d8790af..6cf3b17 100644
--- a/include/swift/AST/GenericSignatureBuilder.h
+++ b/include/swift/AST/GenericSignatureBuilder.h
@@ -450,12 +450,11 @@
/// \returns true if a new rewrite rule was added, and false otherwise.
bool addSameTypeRewriteRule(CanType type1, CanType type2);
- /// \brief Add a new conformance requirement specifying that the given
- /// potential archetypes are equivalent.
- ConstraintResult addSameTypeRequirementBetweenArchetypes(
- PotentialArchetype *T1,
- PotentialArchetype *T2,
- const RequirementSource *Source);
+ /// \brief Add a same-type requirement between two types that are known to
+ /// refer to type parameters.
+ ConstraintResult addSameTypeRequirementBetweenTypeParameters(
+ ResolvedType type1, ResolvedType type2,
+ const RequirementSource *source);
/// \brief Add a new conformance requirement specifying that the given
/// potential archetype is bound to a concrete type.
diff --git a/lib/AST/GenericSignatureBuilder.cpp b/lib/AST/GenericSignatureBuilder.cpp
index b3cf929..158ab66 100644
--- a/lib/AST/GenericSignatureBuilder.cpp
+++ b/lib/AST/GenericSignatureBuilder.cpp
@@ -4828,14 +4828,18 @@
}
ConstraintResult
-GenericSignatureBuilder::addSameTypeRequirementBetweenArchetypes(
- PotentialArchetype *OrigT1,
- PotentialArchetype *OrigT2,
- const RequirementSource *Source)
+GenericSignatureBuilder::addSameTypeRequirementBetweenTypeParameters(
+ ResolvedType type1, ResolvedType type2,
+ const RequirementSource *source)
{
+ // Both sides are type parameters; equate them.
+ // FIXME: Realizes potential archetypes far too early.
+ auto OrigT1 = type1.realizePotentialArchetype(*this);
+ auto OrigT2 = type2.realizePotentialArchetype(*this);
+
// Record the same-type constraint, and bail out if it was already known.
if (!OrigT1->getOrCreateEquivalenceClass(*this)
- ->recordSameTypeConstraint(OrigT1, OrigT2, Source))
+ ->recordSameTypeConstraint(OrigT1, OrigT2, source))
return ConstraintResult::Resolved;
// Operate on the representatives
@@ -4913,7 +4917,7 @@
if (t2IsConcrete) {
if (t1IsConcrete) {
(void)addSameTypeRequirement(equivClass->concreteType,
- equivClass2->concreteType, Source,
+ equivClass2->concreteType, source,
UnresolvedHandlingKind::GenerateConstraints,
SameTypeConflictCheckedLater());
} else {
@@ -5158,15 +5162,9 @@
source.getSource(*this, type1.getDependentType(*this)));
}
- // Both sides are type parameters; equate them.
- // FIXME: Realizes potential archetypes far too early.
- auto pa1 = type1.realizePotentialArchetype(*this);
- auto pa2 = type2.realizePotentialArchetype(*this);
-
- return addSameTypeRequirementBetweenArchetypes(
- pa1, pa2,
- source.getSource(*this,
- type2.getDependentType(*this)));
+ return addSameTypeRequirementBetweenTypeParameters(
+ type1, type2,
+ source.getSource(*this, type2.getDependentType(*this)));
}
ConstraintResult GenericSignatureBuilder::addInheritedRequirements(