Skip to content

Commit

Permalink
Fix pattern cast line numbers (#5228)
Browse files Browse the repository at this point in the history
  • Loading branch information
johannescoetzee authored Jan 14, 2025
1 parent ee19e27 commit 48d26b5
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -190,7 +190,9 @@ trait AstForPatternExpressionsCreator { this: AstCreator =>
newOperatorCallNode(
Operators.cast,
s"(${castType.code}) ${initializerAst.rootCodeOrEmpty}",
Option(patternType)
Option(patternType),
line(patternExpr),
column(patternExpr)
)
callAst(castNode, Ast(castType) :: initializerAst :: Nil)
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2173,6 +2173,8 @@ class PatternExprTests extends JavaSrcCode2CpgFixture {
oCast.name shouldBe Operators.cast
oCast.code shouldBe "(Box) o"
oCast.typeFullName shouldBe "box.Box"
oCast.lineNumber shouldBe Some(9)
oCast.columnNumber shouldBe Some(12)

inside(oCast.argument.l) { case List(boxType: TypeRef, oIdentifier: Identifier) =>
boxType.typeFullName shouldBe "box.Box"
Expand Down

0 comments on commit 48d26b5

Please sign in to comment.