Skip to content

Commit 824ecdd

Browse files
committed
ASTScope: Fix AttachedPropertyWrapperScope source range
The source range needs to contain the argument expression.
1 parent 171e0e2 commit 824ecdd

File tree

2 files changed

+2
-13
lines changed

2 files changed

+2
-13
lines changed

include/swift/AST/ASTScope.h

Lines changed: 1 addition & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -966,19 +966,8 @@ class AttachedPropertyWrapperScope final : public ASTScopeImpl {
966966
CustomAttr *attr;
967967
VarDecl *decl;
968968

969-
/// Because we have to avoid request cycles, we approximate the test for an
970-
/// AttachedPropertyWrapper with one based on source location. We might get
971-
/// false positives, that that doesn't hurt anything. However, the result of
972-
/// the conservative source range computation doesn't seem to be stable. So
973-
/// keep the original here, and use it for source range queries.
974-
const SourceRange sourceRangeWhenCreated;
975-
976969
AttachedPropertyWrapperScope(CustomAttr *attr, VarDecl *decl)
977-
: attr(attr), decl(decl),
978-
sourceRangeWhenCreated(attr->getTypeRepr()->getSourceRange()) {
979-
ASTScopeAssert(sourceRangeWhenCreated.isValid(),
980-
"VarDecls must have ranges to be looked-up");
981-
}
970+
: attr(attr), decl(decl) {}
982971
virtual ~AttachedPropertyWrapperScope() {}
983972

984973
protected:

lib/AST/ASTScopeSourceRange.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -448,7 +448,7 @@ SourceRange ClosureParametersScope::getSourceRangeOfThisASTNode(
448448

449449
SourceRange AttachedPropertyWrapperScope::getSourceRangeOfThisASTNode(
450450
const bool omitAssertions) const {
451-
return sourceRangeWhenCreated;
451+
return attr->getRange();
452452
}
453453

454454
SourceRange GuardStmtScope::getSourceRangeOfThisASTNode(

0 commit comments

Comments
 (0)