@@ -5125,7 +5125,8 @@ swift::findGenericParameterReferences(const ValueDecl *value,
51255125 GenericTypeParamType *origParam,
51265126 GenericTypeParamType *openedParam,
51275127 std::optional<unsigned > skipParamIndex) {
5128- assert (!isa<TypeDecl>(value));
5128+ if (isa<TypeDecl>(value))
5129+ return GenericParameterReferenceInfo ();
51295130
51305131 auto type = value->getInterfaceType ();
51315132
@@ -5150,26 +5151,13 @@ swift::findGenericParameterReferences(const ValueDecl *value,
51505151 /* canBeCovariantResult=*/ true );
51515152}
51525153
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 ());
51655157
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>();
51715160
5172- auto genericParam = sig.getGenericParams ().front ();
51735161 return findGenericParameterReferences (this , sig, genericParam, genericParam,
51745162 std::nullopt );
51755163}
0 commit comments