Skip to content

Commit bf038c2

Browse files
committed
AST: TapExpr should return sub-expression's source locations if set.
Without source location, TapExpr could stop IDE from collecting parameters while perform refactoring. rdar://47835267
1 parent c6bcba6 commit bf038c2

File tree

2 files changed

+14
-2
lines changed

2 files changed

+14
-2
lines changed

include/swift/AST/Expr.h

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -951,8 +951,11 @@ class TapExpr : public Expr {
951951
BraceStmt * getBody() const { return Body; }
952952
void setBody(BraceStmt * b) { Body = b; }
953953

954-
SourceLoc getLoc() const { return SourceLoc(); }
955-
SourceRange getSourceRange() const { return SourceRange(); }
954+
SourceLoc getLoc() const { return SubExpr ? SubExpr->getLoc() : SourceLoc(); }
955+
956+
SourceRange getSourceRange() const {
957+
return SubExpr ? SubExpr->getSourceRange() : SourceRange();
958+
}
956959

957960
static bool classof(const Expr *E) {
958961
return E->getKind() == ExprKind::Tap;
Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
func test(x: Int, y: Int) {
2+
let z = "x = \(x), y = \(y)"
3+
print(z)
4+
}
5+
6+
// RUN: %target-swift-ide-test -range -pos=2:1 -end-pos 4:1 -source-filename %s | %FileCheck %s -check-prefix=CHECK-PARAMS
7+
8+
// CHECK-PARAMS: <Referenced>x</Referenced><Type>Int</Type>
9+
// CHECK-PARAMS: <Referenced>y</Referenced><Type>Int</Type>

0 commit comments

Comments
 (0)