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

Erased arguments not handled in coverage #15505

Closed
nicolasstucki opened this issue Jun 22, 2022 · 0 comments · Fixed by #15530
Closed

Erased arguments not handled in coverage #15505

nicolasstucki opened this issue Jun 22, 2022 · 0 comments · Fixed by #15530
Assignees
Labels
area:coverage Code coverage, see https://dotty.epfl.ch/docs/internals/coverage.html area:experimental:erased-definitions itype:bug
Milestone

Comments

@nicolasstucki
Copy link
Contributor

nicolasstucki commented Jun 22, 2022

Compiler version

3.1.2-RC1

Minimized code

test.scala

import scala.language.experimental.erasedDefinitions

erased def e(x: String): String = "x".toString
def foo(erased a: String)(b: String): String = b
def bar(x: String): String = x

def test: Unit = foo(e("aaa"))(bar("xyz"))

Output

> scalac test.scala -coverage-out:. -Xprint:instrumentCoverage
[[syntax trees at end of        instrumentCoverage]] // tests/coverage/run/erased-def/test.scala
package <empty> {
  import scala.language.experimental.erasedDefinitions
  final lazy module val test$package: test$package = new test$package()
  @SourceFile("tests/coverage/run/erased-def/test.scala") final module class 
    test$package
  () extends Object() { this: test$package.type =>
    private def writeReplace(): AnyRef = 
      new scala.runtime.ModuleSerializationProxy(classOf[test$package.type])
    erased def e(x: String): String = "x".toString()
    def foo(erased a: String)(b: String): String = 
      {
        scala.runtime.coverage.Invoker.invoked(0, ".")
        b
      }
    def bar(x: String): String = 
      {
        scala.runtime.coverage.Invoker.invoked(1, ".")
        x
      }
    def test: Unit = 
      {
        scala.runtime.coverage.Invoker.invoked(5, ".")
        {
          {
            val a$1: String = 
              {
                scala.runtime.coverage.Invoker.invoked(2, ".")
                e("aaa")
              }
            val b$1: String = 
              {
                scala.runtime.coverage.Invoker.invoked(3, ".")
                bar("xyz")
              }
            {
              scala.runtime.coverage.Invoker.invoked(4, ".")
              foo(a$1)(b$1)
            }
          }
          ()
        }
      }
  }
}

-- Error: tests/coverage/run/erased-def/test.scala:7:21 ------------------------
7 |def test: Unit = foo(e("aaa"))(bar("xyz"))
  |                     ^
  |                     method e is declared as `erased`, but is in fact used
1 error found

Expectation

This erased arguments should not be instrumented/lifted and therefore should not emit the error.

@nicolasstucki nicolasstucki added itype:bug area:experimental:erased-definitions area:coverage Code coverage, see https://dotty.epfl.ch/docs/internals/coverage.html labels Jun 22, 2022
@TheElectronWill TheElectronWill self-assigned this Jun 25, 2022
TheElectronWill added a commit to TheElectronWill/dotty that referenced this issue Jun 25, 2022
TheElectronWill added a commit to TheElectronWill/dotty that referenced this issue Jul 2, 2022
TheElectronWill added a commit to TheElectronWill/dotty that referenced this issue Jul 2, 2022
bishabosha pushed a commit to dotty-staging/dotty that referenced this issue Oct 18, 2022
@Kordyjan Kordyjan added this to the 3.2.1 milestone Aug 1, 2023
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 area:experimental:erased-definitions itype:bug
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants