Skip to content

Regression in yurikpanic/zio-postgres - ambigious extension methods prevent type reduction #20288

Closed
@WojciechMazur

Description

@WojciechMazur

Based on OpenCB failure in yurikpanic/zio-postgres - build logs

Compiler version

Last good release: 3.5.0-RC1-bin-20240406-521ce95-NIGHTLY
First bad release: 3.5.0-RC1-bin-20240408-1e8a653-NIGHTLY

Failed to finish bisect - the compiler fails to compile, first bad commit can by any of 389f5be 1dc5b99

Minimized code

trait Decoder[A]
object Decoder {
  given Decoder[DataRow] = ???
  extension [A <: Tuple](d: Decoder[A])
    def ~[B](fd: Field[B]): Decoder[Tuple.Concat[A, Tuple1[B]]] = ???
}

trait Field[A]
object Field:
  val int: Field[Int] = ???
  extension [A](self: Field[A])
    def ~[B](that: Field[B])(using Decoder[DataRow]): Decoder[(A, B)] = ???

trait DataRow
def simpleQuery[S, A](query: String)(using Decoder[A]): Either[Throwable, A] = ???

@main def Test = {
  import Decoder.*
  val fails = simpleQuery("")(using
    Field.int ~ Field.int ~ Field.int
  )
}

Output

-- [E007] Type Mismatch Error: /Users/wmazur/projects/dotty/bisect/sandbox.scala:20:4 
20 |    Field.int ~ Field.int ~ Field.int
   |    ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
   |    Found:    Decoder[(Int, Int, Int)]
   |    Required: Decoder[Tuple.Concat[(Int, Int), Tuple1[Int]]]
   |
   | longer explanation available when compiling with `-explain`

Expectation

The result type should be fully reduced into tuple.

Metadata

Metadata

Type

No type

Projects

No projects

Milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions