Skip to content

default method arguments which refer to methods are not instrumented correctly #30

@RichardBradley

Description

@RichardBradley

If you add method with a default argument, and the expression for the argument's default value refers to a method or val, then it is always shown as uncovered even if you invoke it.

For example:

object DefaultArgumentsObject { val defaultName = "world" def makeGreeting(name: String = defaultName): String = { s"Hello, $name" } } class DefaultArgumentsObjectTest extends FlatSpec with OneInstancePerTest { "DefaultArgumentsObject" should "execute the default block if no arg is given" in { val result = DefaultArgumentsObject.makeGreeting() assert(result === "Hello, world") } } 

Then "defaultName" is always shown in red.

I have looked into this, but I haven't been able to figure out what's wrong, so I can't submit a fix at this time. I will submit a PR to the scoverage-samples project with a demo.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions