Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Coverage generated for inlined Predef function #15791

Closed
Martomate opened this issue Aug 1, 2022 · 2 comments · Fixed by #16235
Closed

Coverage generated for inlined Predef function #15791

Martomate opened this issue Aug 1, 2022 · 2 comments · Fixed by #16235
Assignees
Labels
area:coverage Code coverage, see https://dotty.epfl.ch/docs/internals/coverage.html itype:bug
Milestone

Comments

@Martomate
Copy link

Compiler version

3.2.0-RC3

Minimized code

@main def a(b: Int): Unit = {
  assert(b == 1)
}

The assert function is part of the Scala 3 library at scala.runtime.stdLibPatches.Predef and has this definition:

transparent inline def assert(inline assertion: Boolean): Unit =
  if !assertion then scala.runtime.Scala3RunTime.assertFailed()

Output

scoverage.coverage contains entries for library/src/scala/runtime/stdLibPatches/Predef.scala.

As a result sbt coverageReport fails with the following error:

No source root found for '/Users/martin/git/myproject/library/src/scala/runtime/stdLibPatches/Predef.scala' (source roots: '/Users/martin/git/myproject/src/main/scala/')

Expectation

No coverage entries should be generated for the Predef file, just like all other files in the Scala library.

This issue seems to be related to #15490.

@Martomate Martomate added itype:bug stat:needs triage Every issue needs to have an "area" and "itype" label labels Aug 1, 2022
@TheElectronWill
Copy link
Member

TheElectronWill commented Aug 1, 2022

I think it would be good to report calls to the standard library (and to any library) as covered, even if they're not in the project's codebase.
It would be better for sbt-coverage not to fail. The issue may be on the sbt-coverage side.

@TheElectronWill TheElectronWill added area:coverage Code coverage, see https://dotty.epfl.ch/docs/internals/coverage.html and removed stat:needs triage Every issue needs to have an "area" and "itype" label labels Aug 1, 2022
@arixmkii
Copy link
Contributor

arixmkii commented Aug 1, 2022

Most probably not on sbt plugin side, but in the core module. But previously they stated that will not fix it at least for Macro libraries scoverage/scalac-scoverage-plugin#474

This case is not purely macro, but an inline. Though it is could be questioned if inlined parts should be reported with external source reference if this is an actual code "placed" elsewhere. Similarly with macro code.

An option to hide this behind some configuration key would be appreciated I believe as in some cases people might don't want the coverage info from sources they don't own.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
area:coverage Code coverage, see https://dotty.epfl.ch/docs/internals/coverage.html itype:bug
Projects
None yet
Development

Successfully merging a pull request may close this issue.

4 participants