Skip to content

False type test cannot be checked at runtime because when matching GADT with dependent type parameters #24557

@eejbyfeldt

Description

@eejbyfeldt

Compiler version

3.7.4, 3.8.1-RC1-bin-20251127-fd2172d-NIGHTLY

Minimized code

object test {
  sealed trait X[T]
  trait Iterable[T]
  case class I[T, C <: Iterable[T]](data: C) extends X[C]

  def t[T](i: X[T]): Any =
    i match {
      case i @ I(_) => i
    }
}

Output

$ scala-cli compile -S 3.nightly gdat.scala -Wall
Compiling project (Scala 3.8.1-RC1-bin-20251127-fd2172d-NIGHTLY, JVM (21))
[warn] ./gdat.scala:7:12
[warn] the type test for test.I[T$1, T] cannot be checked at runtime because its type arguments can't be determined from test.X[T]
[warn]       case i @ I(_) => i
[warn]            ^
Compiled project (Scala 3.8.1-RC1-bin-20251127-fd2172d-NIGHTLY, JVM (21))

Expectation

Compiles without warnings.

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions