@@ -3263,19 +3263,37 @@ SuperclassDeclRequest::evaluate(Evaluator &evaluator,
3263
3263
ArrayRef<ProtocolDecl *>
3264
3264
InheritedProtocolsRequest::evaluate (Evaluator &evaluator,
3265
3265
ProtocolDecl *PD) const {
3266
+ auto &ctx = PD->getASTContext ();
3267
+
3266
3268
llvm::SmallSetVector<ProtocolDecl *, 2 > inherited;
3267
- InvertibleProtocolSet inverses;
3268
- bool anyObject = false ;
3269
- for (const auto &found : getDirectlyInheritedNominalTypeDecls (
3270
- PD, inverses, anyObject)) {
3271
- auto proto = dyn_cast<ProtocolDecl>(found.Item );
3272
- if (proto && proto != PD)
3273
- inherited.insert (proto);
3274
- }
3275
3269
3276
- // FIXME: Apply inverses
3270
+ if (PD->wasDeserialized ()) {
3271
+ auto protoSelfTy = PD->getSelfInterfaceType ();
3272
+ for (auto req : PD->getRequirementSignature ().getRequirements ()) {
3273
+ // Dig out a conformance requirement...
3274
+ if (req.getKind () != RequirementKind::Conformance)
3275
+ continue ;
3276
+
3277
+ // constraining Self.
3278
+ if (!req.getFirstType ()->isEqual (protoSelfTy))
3279
+ continue ;
3280
+
3281
+ inherited.insert (req.getProtocolDecl ());
3282
+ }
3283
+ } else {
3284
+ InvertibleProtocolSet inverses;
3285
+ bool anyObject = false ;
3286
+ for (const auto &found : getDirectlyInheritedNominalTypeDecls (
3287
+ PD, inverses, anyObject)) {
3288
+ auto proto = dyn_cast<ProtocolDecl>(found.Item );
3289
+ if (proto && proto != PD)
3290
+ inherited.insert (proto);
3291
+ }
3292
+
3293
+ // FIXME: Apply inverses
3294
+ }
3277
3295
3278
- return PD-> getASTContext () .AllocateCopy (inherited.getArrayRef ());
3296
+ return ctx .AllocateCopy (inherited.getArrayRef ());
3279
3297
}
3280
3298
3281
3299
ArrayRef<ValueDecl *>
0 commit comments