@@ -9950,13 +9950,30 @@ SourceRange AbstractFunctionDecl::getSignatureSourceRange() const {
99509950 if (isImplicit ())
99519951 return SourceRange ();
99529952
9953- auto paramList = getParameters () ;
9953+ SourceLoc endLoc ;
99549954
9955- auto endLoc = paramList->getSourceRange ().End ;
9956- if (endLoc.isValid ())
9957- return SourceRange (getNameLoc (), endLoc);
9955+ // name(parameter list...) async throws(E)
9956+ if (auto *typeRepr = getThrownTypeRepr ())
9957+ endLoc = typeRepr->getSourceRange ().End ;
9958+ if (endLoc.isInvalid ())
9959+ endLoc = getThrowsLoc ();
9960+ if (endLoc.isInvalid ())
9961+ endLoc = getAsyncLoc ();
99589962
9959- return getNameLoc ();
9963+ if (endLoc.isInvalid ())
9964+ return getParameterListSourceRange ();
9965+ return SourceRange (getNameLoc (), endLoc);
9966+ }
9967+
9968+ SourceRange AbstractFunctionDecl::getParameterListSourceRange () const {
9969+ if (isImplicit ())
9970+ return SourceRange ();
9971+
9972+ auto endLoc = getParameters ()->getSourceRange ().End ;
9973+ if (endLoc.isInvalid ())
9974+ return getNameLoc ();
9975+
9976+ return SourceRange (getNameLoc (), endLoc);
99609977}
99619978
99629979std::optional<Fingerprint> AbstractFunctionDecl::getBodyFingerprint () const {
@@ -10993,43 +11010,32 @@ DestructorDecl *DestructorDecl::getSuperDeinit() const {
1099311010}
1099411011
1099511012SourceRange FuncDecl::getSourceRange () const {
10996- SourceLoc StartLoc = getStartLoc ();
11013+ SourceLoc startLoc = getStartLoc ();
1099711014
10998- if (StartLoc .isInvalid ())
11015+ if (startLoc .isInvalid ())
1099911016 return SourceRange ();
1100011017
1100111018 if (getBodyKind () == BodyKind::Unparsed)
11002- return { StartLoc, BodyRange.End };
11003-
11004- SourceLoc RBraceLoc = getOriginalBodySourceRange ().End ;
11005- if (RBraceLoc.isValid ()) {
11006- return { StartLoc, RBraceLoc };
11007- }
11008-
11009- if (isa<AccessorDecl>(this ))
11010- return StartLoc;
11011-
11012- if (getBodyKind () == BodyKind::Synthesize)
11013- return SourceRange ();
11014-
11015- auto TrailingWhereClauseSourceRange = getGenericTrailingWhereClauseSourceRange ();
11016- if (TrailingWhereClauseSourceRange.isValid ())
11017- return { StartLoc, TrailingWhereClauseSourceRange.End };
11019+ return { startLoc, BodyRange.End };
1101811020
11019- const auto ResultTyEndLoc = getResultTypeSourceRange ().End ;
11020- if (ResultTyEndLoc.isValid ())
11021- return { StartLoc, ResultTyEndLoc };
11021+ SourceLoc endLoc = getOriginalBodySourceRange ().End ;
11022+ if (endLoc.isInvalid ()) {
11023+ if (isa<AccessorDecl>(this ))
11024+ return startLoc;
1102211025
11023- if (hasThrows () )
11024- return { StartLoc, getThrowsLoc () } ;
11026+ if (getBodyKind () == BodyKind::Synthesize )
11027+ return SourceRange () ;
1102511028
11026- if (hasAsync ())
11027- return { StartLoc, getAsyncLoc () };
11029+ endLoc = getGenericTrailingWhereClauseSourceRange ().End ;
11030+ }
11031+ if (endLoc.isInvalid ())
11032+ endLoc = getResultTypeSourceRange ().End ;
11033+ if (endLoc.isInvalid ())
11034+ endLoc = getSignatureSourceRange ().End ;
11035+ if (endLoc.isInvalid ())
11036+ endLoc = startLoc;
1102811037
11029- auto LastParamListEndLoc = getParameters ()->getSourceRange ().End ;
11030- if (LastParamListEndLoc.isValid ())
11031- return { StartLoc, LastParamListEndLoc };
11032- return StartLoc;
11038+ return { startLoc, endLoc };
1103311039}
1103411040
1103511041EnumElementDecl::EnumElementDecl (SourceLoc IdentifierLoc, DeclName Name,
@@ -11133,8 +11139,6 @@ SourceRange ConstructorDecl::getSourceRange() const {
1113311139 SourceLoc End = getOriginalBodySourceRange ().End ;
1113411140 if (End.isInvalid ())
1113511141 End = getGenericTrailingWhereClauseSourceRange ().End ;
11136- if (End.isInvalid ())
11137- End = getThrowsLoc ();
1113811142 if (End.isInvalid ())
1113911143 End = getSignatureSourceRange ().End ;
1114011144
0 commit comments