Skip to content

Commit

Permalink
[javasrc2cpg] Fix record accessor call receiver in pattern matches (#…
Browse files Browse the repository at this point in the history
  • Loading branch information
johannescoetzee authored Feb 10, 2025
1 parent e1e007e commit f84df89
Show file tree
Hide file tree
Showing 2 changed files with 2 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -109,7 +109,7 @@ trait AstForPatternExpressionsCreator { this: AstCreator =>
fieldTypeFullName.orElse(Option(defaultTypeFallback()))
)

val fieldAccessorAst = callAst(fieldAccessorCall, lhsAst :: Nil)
val fieldAccessorAst = callAst(fieldAccessorCall, Nil, Option(lhsAst))

val patternInitWithRef = if (requiresTemporaryVariable) {
val patternInitWithRef = initAndRefAstsForPatternInitializer(patternExpr, fieldAccessorAst)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1337,7 +1337,7 @@ class PatternExprTests extends JavaSrcCode2CpgFixture {
valueCall.code shouldBe "((Box) o).value()"
valueCall.typeFullName shouldBe "java.lang.String"

inside(valueCall.argument.l) { case List(boxCast: Call) =>
inside(valueCall.receiver.l) { case List(boxCast: Call) =>
boxCast.name shouldBe Operators.cast
boxCast.code shouldBe "(Box) o"
boxCast.typeFullName shouldBe "box.Box"
Expand Down

0 comments on commit f84df89

Please sign in to comment.