@@ -284,7 +284,9 @@ const RequirementSource *RequirementSource::forRequirementSignature(
284
284
}
285
285
286
286
const RequirementSource *RequirementSource::forNestedTypeNameMatch (
287
- GenericSignatureBuilder &builder) {
287
+ PotentialArchetype *root) {
288
+ auto &builder = *root->getBuilder ();
289
+ // FIXME: Store the root
288
290
REQUIREMENT_SOURCE_FACTORY_BODY_NOSTORAGE (NestedTypeNameMatch, nullptr );
289
291
}
290
292
@@ -724,7 +726,8 @@ bool GenericSignatureBuilder::PotentialArchetype::addConformance(
724
726
// and make it equivalent to the first potential archetype we encountered.
725
727
auto otherPA = new PotentialArchetype (this , assocType);
726
728
known->second .push_back (otherPA);
727
- auto sameNamedSource = RequirementSource::forNestedTypeNameMatch (builder);
729
+ auto sameNamedSource = RequirementSource::forNestedTypeNameMatch (
730
+ known->second .front ());
728
731
builder.addSameTypeRequirement (known->second .front (), otherPA,
729
732
sameNamedSource);
730
733
@@ -980,9 +983,6 @@ auto GenericSignatureBuilder::PotentialArchetype::getNestedType(
980
983
if (rep != this )
981
984
repNested = rep->getNestedType (nestedName, builder);
982
985
983
- auto sameNestedTypeSource =
984
- RequirementSource::forNestedTypeNameMatch (builder);
985
-
986
986
// Attempt to resolve this nested type to an associated type
987
987
// of one of the protocols to which the parent potential
988
988
// archetype conforms.
@@ -1048,9 +1048,11 @@ auto GenericSignatureBuilder::PotentialArchetype::getNestedType(
1048
1048
ProtocolConformanceRef (proto));
1049
1049
type = type.subst (subMap, SubstFlags::UseErrorType);
1050
1050
1051
- builder.addSameTypeRequirement (ResolvedType::forNewTypeAlias (pa),
1052
- builder.resolve (type),
1053
- sameNestedTypeSource, diagnoseMismatch);
1051
+ builder.addSameTypeRequirement (
1052
+ ResolvedType::forNewTypeAlias (pa),
1053
+ builder.resolve (type),
1054
+ RequirementSource::forNestedTypeNameMatch (pa),
1055
+ diagnoseMismatch);
1054
1056
} else
1055
1057
continue ;
1056
1058
@@ -1063,14 +1065,18 @@ auto GenericSignatureBuilder::PotentialArchetype::getNestedType(
1063
1065
1064
1066
// Produce a same-type constraint between the two same-named
1065
1067
// potential archetypes.
1066
- builder.addSameTypeRequirement (pa, nested.front (), sameNestedTypeSource,
1067
- diagnoseMismatch);
1068
+ builder.addSameTypeRequirement (
1069
+ pa, nested.front (),
1070
+ RequirementSource::forNestedTypeNameMatch (pa),
1071
+ diagnoseMismatch);
1068
1072
} else {
1069
1073
nested.push_back (pa);
1070
1074
1071
1075
if (repNested) {
1072
- builder.addSameTypeRequirement (pa, repNested, sameNestedTypeSource,
1073
- diagnoseMismatch);
1076
+ builder.addSameTypeRequirement (
1077
+ pa, repNested,
1078
+ RequirementSource::forNestedTypeNameMatch (pa),
1079
+ diagnoseMismatch);
1074
1080
}
1075
1081
}
1076
1082
@@ -1097,7 +1103,8 @@ auto GenericSignatureBuilder::PotentialArchetype::getNestedType(
1097
1103
if (isConcreteType ()) {
1098
1104
for (auto equivT : rep->getEquivalenceClassMembers ()) {
1099
1105
concretizeNestedTypeFromConcreteParent (
1100
- equivT, sameNestedTypeSource, nestedPA, builder,
1106
+ equivT, RequirementSource::forNestedTypeNameMatch (nestedPA),
1107
+ nestedPA, builder,
1101
1108
[&](ProtocolDecl *proto) -> ProtocolConformanceRef {
1102
1109
auto depTy = nestedPA->getDependentType ({},
1103
1110
/* allowUnresolved=*/ true )
@@ -1936,13 +1943,13 @@ bool GenericSignatureBuilder::addSameTypeRequirementBetweenArchetypes(
1936
1943
}
1937
1944
1938
1945
// Recursively merge the associated types of T2 into T1.
1939
- auto sameNestedTypeSource = RequirementSource::forNestedTypeNameMatch (*this );
1940
1946
for (auto equivT2 : equivClass2Members) {
1941
1947
for (auto T2Nested : equivT2->NestedTypes ) {
1942
1948
auto T1Nested = T1->getNestedType (T2Nested.first , *this );
1943
- if (addSameTypeRequirement (T1Nested, T2Nested.second .front (),
1944
- sameNestedTypeSource,
1945
- [&](Type type1, Type type2) {
1949
+ if (addSameTypeRequirement (
1950
+ T1Nested, T2Nested.second .front (),
1951
+ RequirementSource::forNestedTypeNameMatch (T1Nested),
1952
+ [&](Type type1, Type type2) {
1946
1953
Diags.diagnose (Source->getLoc (),
1947
1954
diag::requires_same_type_conflict,
1948
1955
T1Nested->isGenericParam (),
@@ -2695,7 +2702,7 @@ GenericSignatureBuilder::finalize(SourceLoc loc,
2695
2702
*this );
2696
2703
addSameTypeRequirement (
2697
2704
pa, replacement,
2698
- RequirementSource::forNestedTypeNameMatch (* this ));
2705
+ RequirementSource::forNestedTypeNameMatch (pa ));
2699
2706
});
2700
2707
}
2701
2708
}
0 commit comments