Skip to content

Typer regression for users of scalanlp/breeze #24686

@WojciechMazur

Description

@WojciechMazur

Based on OpenCB failure in:

Compiler version

Last good release: 3.8.0-RC1-bin-20251103-714f3b6-NIGHTLY
First bad release: 3.8.0-RC1-bin-20251104-b83b3d9-NIGHTLY

Bisect points to one of:
f3aea49
5b03dca
Both are commits from #24231

Not present in 3.8.0-RCs, merged after 3.8.0 cutoff, but before change of build developed version

Minimized code

Important note: Original code used implcit instead of givens, but both variants reproduce the issue, code base used specialization so it might have behaved differently on Scala 2.13

def Test = Seq.empty[DenseMatrix[Double]].reduce(DenseMatrix.horzcat(_, _))

trait Matrix[T]
trait DenseMatrix[T] extends Matrix[T]

object DenseMatrix:
    def horzcat[M, V](matrices: M*)(using OpSet.InPlaceImpl2[DenseMatrix[V], M]): DenseMatrix[V] = ???

object OpSet extends HasOps:
  trait InPlaceImpl2[V1, V2]

trait HasOps 
object HasOps extends DenseMatrixExpandedOps with DensMatrixLowPriority

trait DenseMatrixExpandedOps:
  given OpSet.InPlaceImpl2[DenseMatrix[Double], DenseMatrix[Double]] = ???

trait DensMatrixLowPriority extends LowPriorityDenseMatrix1
trait LowPriorityDenseMatrix1: 
  given [V]: OpSet.InPlaceImpl2[DenseMatrix[V], Matrix[V]] = ???

Output

-- [E172] Type Error: /Users/wmazur/projects/scala/community-build3/test.scala:1:74 
1 |def Test = Seq.empty[DenseMatrix[Double]].reduce(DenseMatrix.horzcat(_, _))
  |                                                                          ^
  |Ambiguous given instances: both given instance given_InPlaceImpl2_DenseMatrix_DenseMatrix in
  |  trait DenseMatrixExpandedOps and given instance given_InPlaceImpl2_DenseMatrix_Matrix in
  |  trait LowPriorityDenseMatrix1 match type OpSet.InPlaceImpl2[DenseMatrix[Double], M] of parameter x$2 of method horzcat in object DenseMatrix
1 error found

Expectation

Should continue to compile

Metadata

Metadata

Assignees

Labels

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions