Open Katrix opened 1 year ago
Possible duplicate of https://github.com/lampepfl/dotty/issues/7586
This example works if we disable the following divergence check:
sbt:scala3> scalac -Xprint:typer test.scala
...
[[syntax trees at end of typer]] // test.scala
package <empty> {
...
final module class Test() extends Object() { this: Test.type =>
def main(args: Array[String]): Unit =
{
implicitly[Sum.Aux[Test._1, Test._3, Test._4]](
Sum.sum2[_0, Succ[Test._2], Succ[Test._3]](Sum.sum1[Succ[Test._3]])
)
{
implicitly[Sum.Aux[Test._2, Test._3, Test._5]](
Sum.sum2[Succ[_0], Succ[Test._2], Succ[Test._4]](
Sum.sum2[_0, Succ[Succ[Test._2]], Succ[Test._4]](
Sum.sum1[Succ[Test._4]]
)
)
)
()
}
}
}
}
test.scala
(click to view)Could the divergence check be too strict?
So I came back to this again to check if it's still a problem with 3.4.0. Seems like it is. However, I also noticed that changing sum2
to this made it compile. Could that give insight into where the problem lies?
implicit def sum2[A <: Nat, B <: Nat]
(implicit sum : Sum[A, Succ[B]]): Aux[Succ[A], B, sum.Out] = new Sum[Succ[A], B] { type Out = sum.Out }
Compiler version
3.2.0-RC2
Minimized code
Output
Expectation
It compiles, as it did in Scala 2