Skip to content

StackOverflowError related to implicits #6119

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

Closed
liufengyun opened this issue Mar 19, 2019 · 1 comment
Closed

StackOverflowError related to implicits #6119

liufengyun opened this issue Mar 19, 2019 · 1 comment

Comments

@liufengyun
Copy link
Contributor

liufengyun commented Mar 19, 2019

The following code is minimized from ScalaTest, which compiles fine in Scala 2.12.8, but causes a stackoverflow in Dotty:

class Test {
  def to[Col[_]](factory: Factory[Int, Col[Int]]): Col[Int] = ???

  to(Vector)

  type Factory[-A, +C] = scala.collection.generic.CanBuildFrom[Nothing, A, C] // Ideally, this would be an opaque type

  implicit def fromCanBuildFromConversion[X, A, C](x: X)(
    implicit toCanBuildFrom: X => scala.collection.generic.CanBuildFrom[Nothing, A, C]): Factory[A, C] = ???

  implicit def genericCompanionToCBF[A, CC[X] <: scala.collection.GenTraversable[X]](
    fact: scala.collection.generic.GenericCompanion[CC]): scala.collection.generic.CanBuildFrom[Any, A, CC[A]] = ???
}

Note that in the above, if we comment out fromCanBuildFromConversion, it compiles both in Scala 2.12.8 and Dotty.

This seems to be the culprit of a compiler hang when working with a test in Scalactic.

Chain(1, 2, 3).to(Vector) shouldBe Vector(1, 2, 3)
@smarter
Copy link
Member

smarter commented Mar 19, 2019

Duplicate of #6058 ?

liufengyun added a commit to dotty-staging/dotty that referenced this issue Mar 25, 2019
odersky added a commit that referenced this issue Mar 27, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants