Skip to content

Cyclic reference error involving CanBuildFrom in implicit objects #3067

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
pweisenburger opened this issue Sep 5, 2017 · 1 comment
Closed

Comments

@pweisenburger
Copy link
Contributor

The following code compiles on Scala but produces a cyclic reference involving trait CanBuildFrom compiler error on Dotty:

class Test[T](f: List[String] => T)

object o {
  implicit object a extends Test(_ map identity)
  implicit object b extends Test(_ map identity)
}
@allanrenucci
Copy link
Contributor

allanrenucci commented Nov 3, 2017

Slightly minimised:

import scala.collection.generic.CanBuildFrom

class Test {
  implicitly[CanBuildFrom[List[_], Int, List[Int]]]

  class Foo[T](x: T)
  implicit object Bar extends Foo(
    implicitly[CanBuildFrom[List[_], Int, List[Int]]]
  )
}
> dotc tests/allan/Test.scala
-- [E045] Syntax Error: tests/allan/Test.scala:21:30 ---------------------------
21 |  implicit object Bar extends Foo(
   |                              ^
   |                           cyclic reference involving trait CanBuildFrom
22 |    implicitly[CanBuildFrom[List[_], Int, List[Int]]]

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

3 participants