-
Notifications
You must be signed in to change notification settings - Fork 1.1k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Possible regression in typer or implicits resolution #15184
Comments
Started with 3ab18a9 |
Minimized a bit more //> using scala "3.1.2"
// //> using scala "3.1.1" // Last working stable version
def test() = {
func(_ => Box(Seq.empty[String]) )
}
def func[R0](to0: Unit => R0): Unit = ???
trait JsonFormat[T]
object JsonFormat{
implicit def immSeqFormat: JsonFormat[Seq[String]] = ???
implicit def iterableFormat: JsonFormat[Iterable[String]] = ???
}
case class Box[A1: JsonFormat](elem: A1) |
@smarter Not sure anything can be done here? |
I don't know, is there a rationale for preferring immSeqFormat over iterableFormat, given that both are applicable and neither is more specific than the other? What logic was the compiler following before? |
@smarter Is it correct then, that when we change the argument of //> using scala "3.1.2"
// //> using scala "3.1.1" // Last working stable version
def test() = {
func(Box(Seq.empty[String]) ) // change here
}
def func[R0](to0: R0): Unit = ??? // change here
trait JsonFormat[T]
object JsonFormat{
implicit def immSeqFormat: JsonFormat[Seq[String]] = ???
implicit def iterableFormat: JsonFormat[Iterable[String]] = ???
}
case class Box[A1: JsonFormat](elem: A1) |
Ah, it's true that we instantiate constrained type variables before doing the implicit search, so we should know that While it would be possible to find for each variable in the tree the corresponding avoidance variable (using logic similar to findParam in legalVar in 3ab18a9), that would be quadratic in the number of variables so best avoided. We already know tvarsInParams is problematic (#7586, #7999), so a larger rethinking of this logic might be warranted, but it's not something I'll have time to look at before September. |
Can we come up with a simpler fix before September? We should avoid having regressions like this if possible. |
I can't think of anything, except attempting a partial revert of 3ab18a9 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. |
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
Based on https://github.com/eed3si9n/sjson-new/blob/3c8e15b504145de07b9a46a87a21b85fbdd97c53/support/scalajson/src/test/scala/sjsonnew/support/scalajson/unsafe/LListFormatSpec.scala#L11-L16
Might need further minimization
Output
Expectation
Should correctly resolve correct implicit, in 3.1.1 compiler choosed
JsonFormat.immSeqFormat
The text was updated successfully, but these errors were encountered: