Simplified situation:
{code:title=Test.scala|borderStyle=solid}
class Gen[+A] //mark1
class Simple1
class Simple2
class Complex
object TestDMCreationContext extends App {
implicit def gen[E](implicit e: E, classTag: scala.reflect.ClassTag[E]): Gen[E] = new Gen[E] //mark2
implicit def c1: Simple1 = new Simple1
implicit def c2: Simple2 = new Simple2 //mark3
implicit def c3(implicit g: Gen[Simple1]): Complex = new Complex
implicitly[Complex]
}
{code}
The error:
Test.scala:13: error: diverging implicit expansion for type Complex
starting with method c3 in object TestDMCreationContext
implicitly[Complex]
^
one error found
When the code with mark1 is changed to: class Gen[A]
or the code with mark2 is changed to implicit def gen[E](implicit e: E): Gen[E] = new Gen[E]
or the code with mark3 is deleted, the compilation successes.
Simplified situation: {code:title=Test.scala|borderStyle=solid} class Gen[+A] //mark1
class Simple1 class Simple2 class Complex
object TestDMCreationContext extends App { implicit def gen[E](implicit e: E, classTag: scala.reflect.ClassTag[E]): Gen[E] = new Gen[E] //mark2 implicit def c1: Simple1 = new Simple1 implicit def c2: Simple2 = new Simple2 //mark3 implicit def c3(implicit g: Gen[Simple1]): Complex = new Complex
implicitly[Complex] } {code}
The error: Test.scala:13: error: diverging implicit expansion for type Complex starting with method c3 in object TestDMCreationContext implicitly[Complex] ^ one error found
When the code with mark1 is changed to:
class Gen[A]
or the code with mark2 is changed toimplicit def gen[E](implicit e: E): Gen[E] = new Gen[E]
or the code with mark3 is deleted, the compilation successes.I think this is the bug about materialization