@@ -9939,13 +9939,30 @@ SourceRange AbstractFunctionDecl::getSignatureSourceRange() const {
99399939 if (isImplicit ())
99409940 return SourceRange ();
99419941
9942- auto paramList = getParameters () ;
9942+ SourceLoc endLoc ;
99439943
9944- auto endLoc = paramList->getSourceRange ().End ;
9945- if (endLoc.isValid ())
9946- return SourceRange (getNameLoc (), endLoc);
9944+ // name(parameter list...) async throws(E)
9945+ if (auto *typeRepr = getThrownTypeRepr ())
9946+ endLoc = typeRepr->getSourceRange ().End ;
9947+ if (endLoc.isInvalid ())
9948+ endLoc = getThrowsLoc ();
9949+ if (endLoc.isInvalid ())
9950+ endLoc = getAsyncLoc ();
99479951
9948- return getNameLoc ();
9952+ if (endLoc.isInvalid ())
9953+ return getParameterListSourceRange ();
9954+ return SourceRange (getNameLoc (), endLoc);
9955+ }
9956+
9957+ SourceRange AbstractFunctionDecl::getParameterListSourceRange () const {
9958+ if (isImplicit ())
9959+ return SourceRange ();
9960+
9961+ auto endLoc = getParameters ()->getSourceRange ().End ;
9962+ if (endLoc.isInvalid ())
9963+ return getNameLoc ();
9964+
9965+ return SourceRange (getNameLoc (), endLoc);
99499966}
99509967
99519968std::optional<Fingerprint> AbstractFunctionDecl::getBodyFingerprint () const {
@@ -10982,43 +10999,32 @@ DestructorDecl *DestructorDecl::getSuperDeinit() const {
1098210999}
1098311000
1098411001SourceRange FuncDecl::getSourceRange () const {
10985- SourceLoc StartLoc = getStartLoc ();
11002+ SourceLoc startLoc = getStartLoc ();
1098611003
10987- if (StartLoc .isInvalid ())
11004+ if (startLoc .isInvalid ())
1098811005 return SourceRange ();
1098911006
1099011007 if (getBodyKind () == BodyKind::Unparsed)
10991- return { StartLoc, BodyRange.End };
10992-
10993- SourceLoc RBraceLoc = getOriginalBodySourceRange ().End ;
10994- if (RBraceLoc.isValid ()) {
10995- return { StartLoc, RBraceLoc };
10996- }
10997-
10998- if (isa<AccessorDecl>(this ))
10999- return StartLoc;
11000-
11001- if (getBodyKind () == BodyKind::Synthesize)
11002- return SourceRange ();
11003-
11004- auto TrailingWhereClauseSourceRange = getGenericTrailingWhereClauseSourceRange ();
11005- if (TrailingWhereClauseSourceRange.isValid ())
11006- return { StartLoc, TrailingWhereClauseSourceRange.End };
11008+ return { startLoc, BodyRange.End };
1100711009
11008- const auto ResultTyEndLoc = getResultTypeSourceRange ().End ;
11009- if (ResultTyEndLoc.isValid ())
11010- return { StartLoc, ResultTyEndLoc };
11010+ SourceLoc endLoc = getOriginalBodySourceRange ().End ;
11011+ if (endLoc.isInvalid ()) {
11012+ if (isa<AccessorDecl>(this ))
11013+ return startLoc;
1101111014
11012- if (hasThrows () )
11013- return { StartLoc, getThrowsLoc () } ;
11015+ if (getBodyKind () == BodyKind::Synthesize )
11016+ return SourceRange () ;
1101411017
11015- if (hasAsync ())
11016- return { StartLoc, getAsyncLoc () };
11018+ endLoc = getGenericTrailingWhereClauseSourceRange ().End ;
11019+ }
11020+ if (endLoc.isInvalid ())
11021+ endLoc = getResultTypeSourceRange ().End ;
11022+ if (endLoc.isInvalid ())
11023+ endLoc = getSignatureSourceRange ().End ;
11024+ if (endLoc.isInvalid ())
11025+ endLoc = startLoc;
1101711026
11018- auto LastParamListEndLoc = getParameters ()->getSourceRange ().End ;
11019- if (LastParamListEndLoc.isValid ())
11020- return { StartLoc, LastParamListEndLoc };
11021- return StartLoc;
11027+ return { startLoc, endLoc };
1102211028}
1102311029
1102411030EnumElementDecl::EnumElementDecl (SourceLoc IdentifierLoc, DeclName Name,
@@ -11122,8 +11128,6 @@ SourceRange ConstructorDecl::getSourceRange() const {
1112211128 SourceLoc End = getOriginalBodySourceRange ().End ;
1112311129 if (End.isInvalid ())
1112411130 End = getGenericTrailingWhereClauseSourceRange ().End ;
11125- if (End.isInvalid ())
11126- End = getThrowsLoc ();
1112711131 if (End.isInvalid ())
1112811132 End = getSignatureSourceRange ().End ;
1112911133
0 commit comments