@@ -5125,7 +5125,8 @@ swift::findGenericParameterReferences(const ValueDecl *value,
5125
5125
GenericTypeParamType *origParam,
5126
5126
GenericTypeParamType *openedParam,
5127
5127
std::optional<unsigned > skipParamIndex) {
5128
- assert (!isa<TypeDecl>(value));
5128
+ if (isa<TypeDecl>(value))
5129
+ return GenericParameterReferenceInfo ();
5129
5130
5130
5131
auto type = value->getInterfaceType ();
5131
5132
@@ -5150,26 +5151,13 @@ swift::findGenericParameterReferences(const ValueDecl *value,
5150
5151
/* canBeCovariantResult=*/ true );
5151
5152
}
5152
5153
5153
- GenericParameterReferenceInfo ValueDecl::findExistentialSelfReferences (
5154
- Type baseTy) const {
5155
- assert (baseTy->isExistentialType ());
5156
- assert (!baseTy->hasTypeParameter ());
5157
-
5158
- // Type declarations don't really have type signatures.
5159
- if (isa<TypeDecl>(this ))
5160
- return GenericParameterReferenceInfo ();
5161
-
5162
- // Skip invalid declarations.
5163
- if (getInterfaceType ()->hasError ())
5164
- return GenericParameterReferenceInfo ();
5154
+ GenericParameterReferenceInfo ValueDecl::findExistentialSelfReferences () const {
5155
+ auto *dc = getDeclContext ();
5156
+ ASSERT (dc->getSelfProtocolDecl ());
5165
5157
5166
- // Note: a non-null GenericSignature would violate the invariant that
5167
- // the protocol 'Self' type referenced from the requirement's interface
5168
- // type is the same as the existential 'Self' type.
5169
- auto sig = getASTContext ().getOpenedExistentialSignature (baseTy,
5170
- GenericSignature ());
5158
+ auto sig = dc->getGenericSignatureOfContext ().getCanonicalSignature ();
5159
+ auto genericParam = dc->getSelfInterfaceType ()->castTo <GenericTypeParamType>();
5171
5160
5172
- auto genericParam = sig.getGenericParams ().front ();
5173
5161
return findGenericParameterReferences (this , sig, genericParam, genericParam,
5174
5162
std::nullopt );
5175
5163
}
0 commit comments