@@ -697,6 +697,12 @@ struct GenericSignatureBuilder::Implementation {
697
697
// / Whether there were any errors.
698
698
bool HadAnyError = false ;
699
699
700
+ // / All explicit non-same type requirements that were added to the builder.
701
+ SmallVector<ExplicitRequirement, 2 > ExplicitRequirements;
702
+
703
+ // / All explicit same-type requirements that were added to the builder.
704
+ SmallVector<Requirement, 2 > ExplicitSameTypeRequirements;
705
+
700
706
// / A mapping of redundant explicit requirements to the best root requirement
701
707
// / that implies them.
702
708
using RedundantRequirementMap =
@@ -4500,6 +4506,11 @@ ConstraintResult GenericSignatureBuilder::addConformanceRequirement(
4500
4506
FloatingRequirementSource source) {
4501
4507
auto resolvedSource = source.getSource (*this , type);
4502
4508
4509
+ if (!resolvedSource->isDerivedRequirement ()) {
4510
+ Impl->ExplicitRequirements .emplace_back (RequirementKind::Conformance,
4511
+ resolvedSource, proto);
4512
+ }
4513
+
4503
4514
// Add the conformance requirement, bailing out earlier if we've already
4504
4515
// seen it.
4505
4516
auto equivClass = type.getEquivalenceClass (*this );
@@ -4515,6 +4526,13 @@ ConstraintResult GenericSignatureBuilder::addLayoutRequirementDirect(
4515
4526
ResolvedType type,
4516
4527
LayoutConstraint layout,
4517
4528
FloatingRequirementSource source) {
4529
+ auto resolvedSource = source.getSource (*this , type);
4530
+
4531
+ if (!resolvedSource->isDerivedRequirement ()) {
4532
+ Impl->ExplicitRequirements .emplace_back (RequirementKind::Layout,
4533
+ resolvedSource, layout);
4534
+ }
4535
+
4518
4536
auto equivClass = type.getEquivalenceClass (*this );
4519
4537
4520
4538
// Update the layout in the equivalence class, if we didn't have one already.
@@ -4533,7 +4551,7 @@ ConstraintResult GenericSignatureBuilder::addLayoutRequirementDirect(
4533
4551
4534
4552
// Record this layout constraint.
4535
4553
equivClass->layoutConstraints .push_back ({type.getUnresolvedType (),
4536
- layout, source. getSource (* this , type) });
4554
+ layout, resolvedSource });
4537
4555
equivClass->modified (*this );
4538
4556
++NumLayoutConstraints;
4539
4557
if (!anyChanges) ++NumLayoutConstraintsExtra;
@@ -4651,6 +4669,11 @@ ConstraintResult GenericSignatureBuilder::addSuperclassRequirementDirect(
4651
4669
FloatingRequirementSource source) {
4652
4670
auto resolvedSource = source.getSource (*this , type);
4653
4671
4672
+ if (!resolvedSource->isDerivedRequirement ()) {
4673
+ Impl->ExplicitRequirements .emplace_back (RequirementKind::Superclass,
4674
+ resolvedSource, superclass);
4675
+ }
4676
+
4654
4677
// Record the constraint.
4655
4678
auto equivClass = type.getEquivalenceClass (*this );
4656
4679
equivClass->superclassConstraints .push_back (
@@ -4844,6 +4867,11 @@ GenericSignatureBuilder::addSameTypeRequirementBetweenTypeParameters(
4844
4867
Type depType1 = type1.getDependentType (*this );
4845
4868
Type depType2 = type2.getDependentType (*this );
4846
4869
4870
+ if (!source->isDerivedRequirement ()) {
4871
+ Impl->ExplicitSameTypeRequirements .emplace_back (RequirementKind::SameType,
4872
+ depType1, depType2);
4873
+ }
4874
+
4847
4875
// Record the same-type constraint, and bail out if it was already known.
4848
4876
auto equivClass = type1.getEquivalenceClassIfPresent ();
4849
4877
auto equivClass2 = type2.getEquivalenceClassIfPresent ();
@@ -5068,6 +5096,12 @@ ConstraintResult GenericSignatureBuilder::addSameTypeRequirementToConcrete(
5068
5096
ResolvedType type,
5069
5097
Type concrete,
5070
5098
const RequirementSource *source) {
5099
+ if (!source->isDerivedRequirement ()) {
5100
+ Impl->ExplicitSameTypeRequirements .emplace_back (RequirementKind::SameType,
5101
+ type.getDependentType (*this ),
5102
+ concrete);
5103
+ }
5104
+
5071
5105
auto equivClass = type.getEquivalenceClass (*this );
5072
5106
5073
5107
// Record the concrete type and its source.
0 commit comments