Skip to content

Regression in summoning valueOf with intersection type #24460

@eejbyfeldt

Description

@eejbyfeldt

Compiler version

3.8.0-RC1, 3.8.1-RC1-bin-20251117-5ccea40-NIGHTLY

Works in 3.7.4

Minimized code

//> using scala 3.8.0-RC1
import scala.compiletime.{erasedValue, summonFrom}

object test {
  private inline def singletons[T, Elem <: Tuple]: Seq[T] =
    inline erasedValue[Elem] match {
      case _: EmptyTuple => Seq.empty
      case _: (h *: t) =>
        summonFrom {
          case _: ValueOf[`h`] => valueOf[`h` & T] +: singletons[T, t]
        }
    }

  enum A { case A1, A2, A3 }

  val _ = singletons[A, (A.A1.type, A.A2.type, A.A3.type)]
}

Output

[error] ./value_of_inline.scala:15:11
[error] cannot reduce summonFrom with
[error]  patterns :  case given ev @ _:ValueOf[(test.A.A1 : test.A) & test.A]
[error]   val _ = singletons[A, (A.A1.type, A.A2.type, A.A3.type)]
[error]           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

Expectation

Compiles like 3.7.4.

Slightly related to #24237

Metadata

Metadata

Assignees

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions