scala/scala3

Coverage misses expression with `-Yexplicit-nulls` and `.nn`

Opened this issue · 3 comments

Compiler version

3.4.2 and 3.5.0-RC1, so probably all

Minimized code

With -Yexplicit-nulls and coverage enabled (project available at https://github.com/mohe2015/scala3-broken-coverage-explicit-nulls)

@main def hello(): Unit =
  println("Hello world!".nn)

Output

The expression is not marked as covered:

image

Expectation

All code is covered.

Probably has something to do with inline def in general. Maybe it would make sense to have some annotation to influence this.

Related case is probably

@main def hello(): Unit =
  try {
    assert(true, 1 / 0)
    assert(false, 1 / 1)
  } catch {
    case assertionError: AssertionError => assertionError.printStackTrace()
  }

image
where I would argue the 1 / 0 should not be covered at all (white) because as the assertion is true it is not executed but I also think it wouldn't make sense that assertion error messages create missing coverage by default.

Even more cases that may or may not be related. Depending on their root cause they may need a separate issue.

@main def hello(): Unit =
  assert(1 + 1 == 2 + 0)
  assert(true)
  assert(1 < 2)
  assert(Boolean.box(1 == 1))
  assert("hello".size == 5)

image