@@ -778,7 +778,7 @@ ProtocolRethrowsRequirementsRequest::evaluate(Evaluator &evaluator,
778
778
ASTContext &ctx = decl->getASTContext ();
779
779
780
780
// only allow rethrowing requirements to be determined from marked protocols
781
- if (decl->getAttrs ().hasAttribute <swift::AtRethrowsAttr>()) {
781
+ if (! decl->getAttrs ().hasAttribute <swift::AtRethrowsAttr>()) {
782
782
return ProtocolRethrowsRequirementList (ctx.AllocateCopy (found));
783
783
}
784
784
@@ -789,7 +789,7 @@ ProtocolRethrowsRequirementsRequest::evaluate(Evaluator &evaluator,
789
789
// it must have a rethrows attribute
790
790
// it must not have any parameters that are closures that cause rethrowing
791
791
if (!fnDecl ||
792
- !fnDecl->getAttrs (). hasAttribute <RethrowsAttr> ()) {
792
+ !fnDecl->hasThrows ()) {
793
793
continue ;
794
794
}
795
795
@@ -828,22 +828,25 @@ ProtocolRethrowsRequirementsRequest::evaluate(Evaluator &evaluator,
828
828
FunctionRethrowingKind
829
829
FunctionRethrowingKindRequest::evaluate (Evaluator &evaluator,
830
830
AbstractFunctionDecl *decl) const {
831
- if (decl->getAttrs ().hasAttribute <RethrowsAttr>()) {
832
- GenericSignature genericSig = decl->getGenericSignature ();
833
- FunctionRethrowingKind kind = getParameterThrowingKind (decl, genericSig);
834
- // since we have checked all arguments, if we still havent found anything
835
- // check the self parameter
836
- if (kind == FunctionRethrowingKind::Invalid &&
837
- decl->hasImplicitSelfDecl ()) {
838
- auto selfParam = decl->getImplicitSelfDecl ();
839
- if (selfParam) {
840
- auto interfaceTy = selfParam->getInterfaceType ();
841
- kind = getTypeThrowingKind (interfaceTy, genericSig);
831
+ if (decl->hasThrows ()) {
832
+ if (auto proto = dyn_cast<ProtocolDecl>(decl->getDeclContext ())) {
833
+ if (proto->isRethrowingProtocol ()) {
834
+ GenericSignature genericSig = decl->getGenericSignature ();
835
+ FunctionRethrowingKind kind = getParameterThrowingKind (decl, genericSig);
836
+ // since we have checked all arguments, if we still havent found anything
837
+ // check the self parameter
838
+ if (kind == FunctionRethrowingKind::Invalid &&
839
+ decl->hasImplicitSelfDecl ()) {
840
+ auto selfParam = decl->getImplicitSelfDecl ();
841
+ if (selfParam) {
842
+ auto interfaceTy = selfParam->getInterfaceType ();
843
+ kind = getTypeThrowingKind (interfaceTy, genericSig);
844
+ }
845
+ }
846
+
847
+ return kind;
842
848
}
843
849
}
844
-
845
- return kind;
846
- } else if (decl->hasThrows ()) {
847
850
return FunctionRethrowingKind::Throws;
848
851
}
849
852
return FunctionRethrowingKind::None;
0 commit comments