scoverage / scalac-scoverage-plugin

Scoverage Scala Code Coverage Core Libs
https://github.com/scoverage
Apache License 2.0
425 stars 126 forks source link

Handle branches in anonymous function pattern matching #534

Closed jrglee closed 1 year ago

jrglee commented 1 year ago

While adopting my previous contribution in #493, I was still finding case patterns not being counted as branches. This was only in anonymous functions, where the parameter is used as selector, e.g.:

(1 to 100).map {
  case i if i % 2 == 0 => true
  case _ => false
}

The match handling does not instrument the case statements when the selector gets generated. But anonymous functions are a special case because the case statements are written by the user.

The solution in this PR handles anonymous function case by checking if the function body itself is a match node in the AST.

davidhoyt commented 1 year ago

Thank you!! Will there be a new release soon with this? I really appreciate contributors' and maintainers' hard work! 😄

ckipp01 commented 1 year ago

Thank you!! Will there be a new release soon with this? I really appreciate contributors' and maintainers' hard work! 😄

Hey! Just cut a new release so you should be good to update!

davidhoyt commented 1 year ago

Thank you for getting a new release out so quickly!