Skip to content

Erased arguments not handled in coverage #15505

Closed
@nicolasstucki

Description

@nicolasstucki

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.

Metadata

Metadata

Type

No type

Projects

No projects

Milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions