Closed
Description
Compiler version
3.1.2
Works in 3.1.1
Fails in 3.2.0-RC1-bin-20220512-9dbe2d3-NIGHTLY
First bad commit 3ab18a9
Minimized code
Might need further minimization
//> using scala "3.1.2"
// //> using scala "3.1.1" // Last working stable version
def test() = {
given JsonFormat[LCons[Seq[String], LNil]] = ???
case class Foo(xs: Seq[String])
implicit val isoLList: IsoLList[Foo] = LList.isoCurried((a: Foo) => "xs" -> a.xs :*: LNil ){
case (_, xs) :*: LNil => Foo(xs)
}
}
trait JsonFormat[T]
object JsonFormat{
import collection.{immutable => imm}
implicit def immSeqFormat[T :JsonFormat]: JsonFormat[imm.Seq[T]] = ???
import collection._
implicit def iterableFormat[T :JsonFormat]: JsonFormat[Iterable[T]] = ???
given JsonFormat[String] = ???
}
sealed trait LList
object LList{
val LNil0: LNil0 = new LNil0 {}
sealed trait LNil0 extends LList {
def :*:[A1: JsonFormat](labelled: (String, A1)): LCons[A1, LNil] = ???
}
def isoCurried[A, R0 <: LList: JsonFormat](to0: A => R0)(from0: R0 => A): IsoLList.Aux[A, R0] = ???
}
type LNil = LList.LNil0
val LNil = LList.LNil0
final class LCons[A1: JsonFormat, A2 <: LList: JsonFormat] extends LList
type :*:[A1, A2 <: LList] = LCons[A1, A2]
object :*: {
def unapply[H, T <: LList](x: H :*: T): Some[((String, H), T)] = ???
}
trait IsoLList[A]
object IsoLList {
type Aux[A, R0] = IsoLList[A]{ type R = R0 }
}
Output
[error] ./test.scala:40:92: ambiguous implicit arguments: both method immSeqFormat in object JsonFormat and method iterableFormat in object JsonFormat match type JsonFormat[(avoid)A1] of an implicit parameter of method :*: in trait LNil0
[error] implicit val isoLList: IsoLList[Foo] = LList.isoCurried((a: Foo) => "xs" -> a.xs :*: LNil ){
[error] ^
Error compiling project (Scala 3.1.2, JVM)
Expectation
Should correctly resolve correct implicit, in 3.1.1 compiler choosed JsonFormat.immSeqFormat