Skip to content

Commit 536e706

Browse files
authored
Merge pull request #22465 from nkcsgexi/interpolation-extract
AST: TapExpr should return sub-expression's source locations if set.
2 parents 4e0142e + 5617e4a commit 536e706

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
@@ -988,8 +988,11 @@ class TapExpr : public Expr {
988988
BraceStmt * getBody() const { return Body; }
989989
void setBody(BraceStmt * b) { Body = b; }
990990

991-
SourceLoc getLoc() const { return SourceLoc(); }
992-
SourceRange getSourceRange() const { return SourceRange(); }
991+
SourceLoc getLoc() const { return SubExpr ? SubExpr->getLoc() : SourceLoc(); }
992+
993+
SourceRange getSourceRange() const {
994+
return SubExpr ? SubExpr->getSourceRange() : SourceRange();
995+
}
993996

994997
static bool classof(const Expr *E) {
995998
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)