Possible regression in typer or implicits resolution
See original GitHub issueCompiler version
3.1.2 Works in 3.1.1 Fails in 3.2.0-RC1-bin-20220512-9dbe2d3-NIGHTLY
First bad commit 3ab18a90ac24dba440c498aab6a8f0c763589605
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
Issue Analytics
- State:
- Created a year ago
- Comments:8 (7 by maintainers)
Top Results From Across the Web
Implicit resolution regression in 2.13.x. #10425 - scala/bug
I ran into this while working on a fix for #5340 and #4947. The following compiles in 2.12.2 but fails on 2.13.x (including ......
Read more >Implicit Scope and Implicit Resolution in Scala - geekAbyte
First one was to view the implicit resolution process as a Function call. The second was to understand the relationship between the type ......
Read more >The Usefulness of Implicit Regression in Model Quality
Implicit Regression is useful in measuring the constant nature of a measured variable [1]; it helps detect bivariate and multivariate random ...
Read more >Changes in Implicit Resolution - Scala 3 - EPFL
Implicit resolution uses a new algorithm which caches implicit results more aggressively for performance. There are also some changes that affect implicits on ......
Read more >Scala type equality and path-dependent types - Stack Overflow
I don't see a reason to introduce type D in method run. Without it method signature looks simpler and successfully compiles
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
Minimized a bit more
I can’t think of anything, except attempting a partial revert of https://github.com/lampepfl/dotty/commit/3ab18a90ac24dba440c498aab6a8f0c763589605 but even that is beyond what little time I have available right now. It’s unfortunate that we’re finding out about all these regressions now as opposed to when they were introduced or in a few months, timing-wise this is the worst-case scenario and there isn’t anything I can do about it really.