Skip to content

Coverage incorrectly lifts skolem types when capture checking is enabled #26612

Description

@anatoliykmetyuk

Compiler version

3.10.0-RC1-bin-SNAPSHOT - on latest main as of 23 July 2026, commit 7c8ee3cb7e.

Minimized code

abstract class ArrayCloneSeq[A]:
  def array: Array[?]

  def cloneArray: ArrayCloneSeq[A] =
    ArrayCloneSeq.unsafeWrapArray(array.clone()).asInstanceOf[ArrayCloneSeq[A]]

object ArrayCloneSeq:
  def unsafeWrapArray[T](array: Array[T]): ArrayCloneSeq[T] =
    null.asInstanceOf[ArrayCloneSeq[T]]

Command

sbt -error -no-colors "scala3-bootstrapped/scalac -color:never -Yexplicit-nulls -Wsafe-init -language:experimental.captureChecking -coverage-out target/issue-coverage -sourceroot . -d target/issue-out Repro.scala"

Output

-- [E007] Type Mismatch Error: Repro.scala:5:45 -------------------------------
5 |    ArrayCloneSeq.unsafeWrapArray(array.clone()).asInstanceOf[ArrayCloneSeq[A]]
  |                                             ^
  |                     Found:    (array$1 : Array[?]^{})
  |                     Required: Array[?1.T^'s1]
  |
  |                     The error occurred for a synthesized tree:  array$1
  |
  |                     where:    ?1 is an unknown value of type Array[?]^'s2
  |
  | longer explanation available when compiling with `-explain`
1 error found
[error] nonzero exit code returned from runner: 1
[error] (scala3-compiler-bootstrapped / Compile / runMain) nonzero exit code returned from runner: 1

Expectation

Compilation succeeds with coverage instrumentation, matching the no-coverage compile of the same source.

Notes

Is a blocker to enable coverage on the standard library.

Metadata

Metadata

Assignees

No one assigned

    Labels

    area:coverageCode coverage, see https://dotty.epfl.ch/docs/internals/coverage.htmlarea:experimental:ccCapture checking relateditype:bug

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions