File tree Expand file tree Collapse file tree 3 files changed +21
-22
lines changed Expand file tree Collapse file tree 3 files changed +21
-22
lines changed Original file line number Diff line number Diff line change @@ -91,6 +91,16 @@ ProtocolDecl *DeclContext::getAsProtocolExtensionContext() const {
91
91
GenericTypeParamType *DeclContext::getProtocolSelfType () const {
92
92
assert (getAsProtocolOrProtocolExtensionContext () && " not a protocol" );
93
93
94
+ auto genericParams = getGenericParamsOfContext ();
95
+
96
+ if (!genericParams) {
97
+ if (auto proto = dyn_cast<ProtocolDecl>(this )) {
98
+ getASTContext ().getLazyResolver ()
99
+ ->resolveDeclSignature (const_cast <ProtocolDecl *>(proto));
100
+ genericParams = getGenericParamsOfContext ();
101
+ }
102
+ }
103
+
94
104
return getGenericParamsOfContext ()->getParams ().front ()
95
105
->getDeclaredInterfaceType ()
96
106
->castTo <GenericTypeParamType>();
Original file line number Diff line number Diff line change @@ -5168,21 +5168,15 @@ Decl *SwiftDeclConverter::importCompatibilityTypeAlias(
5168
5168
namespace {
5169
5169
template <typename D>
5170
5170
bool inheritanceListContainsProtocol (D decl, const ProtocolDecl *proto) {
5171
- return llvm::any_of (range (decl->getInherited ().size ()),
5172
- [decl, proto](unsigned index) -> bool {
5173
- Type type = decl->getInheritedType (index);
5174
- if (!type || !type->isExistentialType ())
5175
- return false ;
5176
-
5177
- auto layout = type->getExistentialLayout ();
5178
- for (auto protoTy : layout.getProtocols ()) {
5179
- auto *protoDecl = protoTy->getDecl ();
5171
+ bool anyObject = false ;
5172
+ for (const auto &found :
5173
+ getDirectlyInheritedNominalTypeDecls (decl, anyObject)) {
5174
+ if (auto protoDecl = dyn_cast<ProtocolDecl>(found.second ))
5180
5175
if (protoDecl == proto || protoDecl->inheritsFrom (proto))
5181
5176
return true ;
5182
- }
5177
+ }
5183
5178
5184
- return false ;
5185
- });
5179
+ return false ;
5186
5180
}
5187
5181
}
5188
5182
Original file line number Diff line number Diff line change @@ -560,16 +560,11 @@ getInheritedForCycleCheck(TypeChecker &tc,
560
560
ProtocolDecl **scratch) {
561
561
TinyPtrVector<ProtocolDecl *> result;
562
562
563
- for (unsigned index : indices (proto->getInherited ())) {
564
- if (auto type = proto->getInheritedType (index)) {
565
- if (type->isExistentialType ()) {
566
- auto layout = type->getExistentialLayout ();
567
- for (auto protoTy : layout.getProtocols ()) {
568
- auto *protoDecl = protoTy->getDecl ();
569
- result.push_back (protoDecl);
570
- }
571
- }
572
- }
563
+ bool anyObject = false ;
564
+ for (const auto &found :
565
+ getDirectlyInheritedNominalTypeDecls (proto, anyObject)) {
566
+ if (auto protoDecl = dyn_cast<ProtocolDecl>(found.second ))
567
+ result.push_back (protoDecl);
573
568
}
574
569
575
570
return result;
You can’t perform that action at this time.
0 commit comments