@@ -208,32 +208,45 @@ const USRBasedType *USRBasedType::fromType(Type Ty, USRBasedTypeArena &Arena) {
208
208
}
209
209
210
210
SmallVector<const USRBasedType *, 2 > Supertypes;
211
+ ;
211
212
if (auto Nominal = Ty->getAnyNominal ()) {
212
- auto Conformances = Nominal->getAllConformances ();
213
- Supertypes.reserve (Conformances.size ());
214
- for (auto Conformance : Conformances) {
215
- if (Conformance->getDeclContext ()->getParentModule () !=
216
- Nominal->getModuleContext ()) {
217
- // Only include conformances that are declared within the module of the
218
- // type to avoid caching retroactive conformances which might not
219
- // exist when using the code completion cache from a different module.
220
- continue ;
221
- }
222
- if (Conformance->getProtocol ()->isSpecificProtocol (KnownProtocolKind::Sendable)) {
223
- // FIXME: Sendable conformances are lazily synthesized as they are
224
- // needed by the compiler. Depending on whether we checked whether a
225
- // type conforms to Sendable before constructing the USRBasedType, we
226
- // get different results for its conformance. For now, always drop the
227
- // Sendable conformance.
228
- continue ;
213
+ if (auto *Proto = dyn_cast<ProtocolDecl>(Nominal)) {
214
+ Proto->walkInheritedProtocols ([&](ProtocolDecl *inherited) {
215
+ if (Proto != inherited &&
216
+ !inherited->isSpecificProtocol (KnownProtocolKind::Sendable)) {
217
+ Supertypes.push_back (USRBasedType::fromType (
218
+ inherited->getDeclaredInterfaceType (), Arena));
219
+ }
220
+
221
+ return TypeWalker::Action::Continue;
222
+ });
223
+ } else {
224
+ auto Conformances = Nominal->getAllConformances ();
225
+ Supertypes.reserve (Conformances.size ());
226
+ for (auto Conformance : Conformances) {
227
+ if (Conformance->getDeclContext ()->getParentModule () !=
228
+ Nominal->getModuleContext ()) {
229
+ // Only include conformances that are declared within the module of the
230
+ // type to avoid caching retroactive conformances which might not
231
+ // exist when using the code completion cache from a different module.
232
+ continue ;
233
+ }
234
+ if (Conformance->getProtocol ()->isSpecificProtocol (KnownProtocolKind::Sendable)) {
235
+ // FIXME: Sendable conformances are lazily synthesized as they are
236
+ // needed by the compiler. Depending on whether we checked whether a
237
+ // type conforms to Sendable before constructing the USRBasedType, we
238
+ // get different results for its conformance. For now, always drop the
239
+ // Sendable conformance.
240
+ continue ;
241
+ }
242
+ Supertypes.push_back (USRBasedType::fromType (
243
+ Conformance->getProtocol ()->getDeclaredInterfaceType (), Arena));
229
244
}
230
- Supertypes.push_back (USRBasedType::fromType (
231
- Conformance->getProtocol ()->getDeclaredInterfaceType (), Arena));
232
245
}
233
246
}
234
247
235
248
// You would think that superclass + conformances form a DAG. You are wrong!
236
- // We can achieve a circular supertype hierarcy with
249
+ // We can achieve a circular supertype hierarchy with
237
250
//
238
251
// protocol Proto : Class {}
239
252
// class Class : Proto {}
0 commit comments