@@ -820,6 +820,19 @@ const RequirementSource *RequirementSource::getMinimalConformanceSource(
820
820
switch (source->kind ) {
821
821
case ProtocolRequirement:
822
822
case InferredProtocolRequirement: {
823
+ // Special handling for top-level requirement signature requirements;
824
+ // pretend the root type is the subject type as written in the
825
+ // protocol, and not 'Self', so that we can consider this requirement
826
+ // self-derived if it depends on one of the conformances that make
827
+ // the root type valid.
828
+ if (requirementSignatureSelfProto) {
829
+ if (source->getProtocolDecl () == requirementSignatureSelfProto &&
830
+ source->parent ->kind == RequirementSource::RequirementSignatureSelf) {
831
+ rootType = source->getAffectedType ();
832
+ return false ;
833
+ }
834
+ }
835
+
823
836
// Note that we've seen a protocol requirement.
824
837
sawProtocolRequirement = true ;
825
838
@@ -2144,37 +2157,40 @@ void EquivalenceClass::dump(llvm::raw_ostream &out,
2144
2157
}, [&]() {
2145
2158
out << " , " ;
2146
2159
});
2147
- out << " \n Conformances:" ;
2148
- interleave (conformsTo,
2149
- [&](const std::pair<
2150
- ProtocolDecl *,
2151
- std::vector<Constraint<ProtocolDecl *>>> &entry) {
2152
- out << entry.first ->getNameStr ();
2153
- },
2154
- [&] { out << " , " ; });
2155
- out << " \n Same-type constraints:" ;
2156
- llvm::interleave (
2157
- sameTypeConstraints,
2158
- [&](const Constraint<Type> &constraint) {
2159
- out << " \n " << constraint.getSubjectDependentType ({})
2160
- << " == " << constraint.value ;
2160
+ out << " \n " ;
2161
+ out << " Conformance constraints:\n " ;
2162
+ for (auto entry : conformsTo) {
2163
+ out << " " << entry.first ->getNameStr () << " \n " ;
2164
+ for (auto constraint : entry.second ) {
2165
+ constraint.source ->dump (out, &builder->getASTContext ().SourceMgr , 4 );
2166
+ if (constraint.source ->isDerivedRequirement ())
2167
+ out << " [derived]" ;
2168
+ out << " \n " ;
2169
+ }
2170
+ }
2171
+
2172
+ out << " Same-type constraints:\n " ;
2173
+ for (auto constraint : sameTypeConstraints) {
2174
+ out << " " << constraint.getSubjectDependentType ({})
2175
+ << " == " << constraint.value << " \n " ;
2176
+ constraint.source ->dump (out, &builder->getASTContext ().SourceMgr , 4 );
2177
+ if (constraint.source ->isDerivedRequirement ())
2178
+ out << " [derived]" ;
2179
+ out << " \n " ;
2180
+ }
2161
2181
2162
- if (constraint.source ->isDerivedRequirement ())
2163
- out << " [derived]" ;
2164
- },
2165
- [&] { out << " , " ; });
2166
2182
if (concreteType)
2167
- out << " \n Concrete type: " << concreteType.getString ();
2183
+ out << " Concrete type: " << concreteType.getString () << " \n " ;
2168
2184
if (superclass)
2169
- out << " \n Superclass : " << superclass.getString ();
2185
+ out << " Superclass : " << superclass.getString () << " \n " ;
2170
2186
if (layout)
2171
- out << " \n Layout : " << layout.getString ();
2187
+ out << " Layout : " << layout.getString () << " \n " ;
2172
2188
2173
2189
if (!delayedRequirements.empty ()) {
2174
- out << " \n Delayed requirements:" ;
2190
+ out << " Delayed requirements:\n " ;
2175
2191
for (const auto &req : delayedRequirements) {
2176
- out << " \n " ;
2177
2192
req.dump (out);
2193
+ out << " \n " ;
2178
2194
}
2179
2195
}
2180
2196
0 commit comments