Skip to content

Diverging implicit expansion for type for the first implicit parameter search #8773

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

Open
scabug opened this issue Aug 2, 2014 · 3 comments
Labels
fixed in Scala 3 This issue does not exist in the Scala 3 compiler (https://github.com/lampepfl/dotty/) typer
Milestone

Comments

@scabug
Copy link

scabug commented Aug 2, 2014

For the first sight this code looks ok:

class RJF[T] extends JF[T]
class JF[T]
case class G(i: Int)
object JFs {
  implicit val g: RJF[G] = new RJF
}
class M[-T]

implicit def seqRJF[T](implicit jf: JF[T]): RJF[scala.collection.Seq[T]] = new RJF
implicit def iterableRJF[T](implicit jf: JF[T]): RJF[scala.collection.Iterable[T]] = new RJF

implicit def m[T](implicit t: RJF[T]): M[T] = new M

def foo[T](s: T)(implicit m: M[T]) = "text"

import JFs._

foo(Seq(G(1)))(m(seqRJF))

Here compiler will say weird compiler error:
Error:(60, 18) diverging implicit expansion for type HttpApiService.this.JF[T]
starting with method iterableRJF in class HttpApiService
foo(Seq(G(1)))(m(seqRJF))
^

However you can remove explicitly passed seqRJF and everything will be ok. I don't see any reasons of such behaviour.

Another similar example can be found here: http://youtrack.jetbrains.com/issue/SCL-7335#comment=27-772977
That's about original question and why Scala compiler is able to find implicit parameter in that case.

@scabug
Copy link
Author

scabug commented Aug 2, 2014

Imported From: https://issues.scala-lang.org/browse/SI-8773?orig=1
Reporter: @Alefas
Affected Versions: 2.11.1

@antonioortizpola
Copy link

No news in this front yet? it has been 4 years and the bug still exists

@joroKr21
Copy link
Member

joroKr21 commented Mar 4, 2018

This looks related to #10753 - the expected type did not propagate through the implicit search.

@SethTisue SethTisue added this to the Backlog milestone Mar 4, 2018
@SethTisue SethTisue added typer fixed in Scala 3 This issue does not exist in the Scala 3 compiler (https://github.com/lampepfl/dotty/) labels Aug 14, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
fixed in Scala 3 This issue does not exist in the Scala 3 compiler (https://github.com/lampepfl/dotty/) typer
Projects
None yet
Development

No branches or pull requests

4 participants