scala/scala3

Regression in typer

Closed this issue · 2 comments

Based on OpenCB failures in multiple projects. For all of these the bisect was pointing to #21744 528d0f0

Related to #22713 but differs in the commit of bisect result commit

Project Name Version Build Logs Notes
lichess-org/lila HEAD Open CB logs Needs minimization
darrenjw/scala-smfsb 1.1 Open CB logs Reproduction below
etorreborre/specs2 5.5.8 Open CB logs Needs minimization
purplekingdomgames/ultraviolet 0.4.0 Open CB logs Needs minimization
martinhh/scalacheck-derived 0.6.0 -> 0.7.0 Open CB logs Needs minimization
zio/zio 2.1.15 -> 2.1.16 Open CB logs Reproducer below

Compiler version

3.7.0-NIGHTLY

Minimized code

//> using dep org.scala-lang.modules::scala-parallel-collections:1.2.0

import scala.collection.parallel.immutable.ParVector
import scala.collection.parallel.CollectionConverters._

case class PMatrix[T](x: Int, data: ParVector[T]):
  def coflatMap[S](f: PMatrix[T] => S): PMatrix[S] =
    PMatrix(
      x,
      (0 until x).toVector.par.map(i => f(PMatrix(x, data)))
    )

object PMatrix:
  def apply[T](r: Int, c: Int, data: Seq[T]): PMatrix[T] = ???

Output

Compiling project (Scala 3.7.0-RC1-bin-20250304-bef520f-NIGHTLY, JVM (17))
[error] ./test.scala:10:54
[error] Found:    (PMatrix.this.data : scala.collection.parallel.immutable.ParVector[T])
[error] Required: Int
[error]       (0 until x).toVector.par.map(i => f(PMatrix(x, data)))
[error]                                                      

Expectation

Should compile

Additional reproducer from zio/zio:

import java.util.concurrent.atomic.AtomicReference

object UnboundedHub:
  final class Node[A](var value: A, val pointer: AtomicReference[Pointer[A]])
  final case class Pointer[A](node: Node[A], subscribers: Int)

private final class UnboundedHub[A]:
  import UnboundedHub.*

  val publisherHead: AtomicReference[Node[A]] = new AtomicReference(
    new Node[A](
      null.asInstanceOf[A],
      new AtomicReference(
        Pointer(null, 0)
      )
    )
  )

yields

-- Error: /Users/wmazur/projects/scala/community-build3/test.scala:14:15 --------------------------------------------------------------------------------------------------------------------
14 |        Pointer(null, 0)
   |        ^^^^^^^^^^^^^^^^
   |        too many arguments for constructor AtomicReference in class AtomicReference: (): java.util.concurrent.atomic.AtomicReference[UnboundedHub.Pointer[A]]