title: Forward reference extends over definition of value problem
body: <p>i have some problem in scala to resolve implicit values, and i have the cryptic error message in netbeans : </p>
  
  <blockquote>
    <p>"error : Forward reference extends over definition of value ..."</p>
  </blockquote>
  
  <p>or in the scala console i have an other error message</p>
  
  <blockquote>
    <p>"type mistmatch :29: error: type mismatch;  found   :
    Factory.type (with underlying type object Factory)  required:
    GenericFactory"</p>
  </blockquote>
  
  <p>Some description of my class and main function : </p>
  
  <pre><code>import java.util.Random
  
  //////////
  // Main //
  
  //Implicit random for all classes and object
  implicit val aprng = new Random
  
  //Implicit object Factory used in other class
  implicit val factory = Factory
  
  abstract class GenericFactory {
  def build 
  }
  
  object Factory extends GenericFactory{
  def build = println("return factory")
  }
  
  class A (rate: Random =&gt; Double = aprng =&gt; aprng.nextFloat, val factory : GenericFactory) {
  
    def this(rate : Double, factory : GenericFactory) = this( _ =&gt; rate, factory)
  
    def operate(genomes: IndexedSeq[Int])(implicit aprng: Random) = { 
  println("calculate genomes with aprng random values")}
  }
  
  object B{
  val instanceOfA = new A(rate =&gt; 0.5d,factory)
  }
  </code></pre>
  
  <p>I have 2 problem because 1) i can pass an object in argument of class A, so i define an abstract class to pass this abstract class, but that not work here :/ 
  2) After that, my implicit value defined into class A is not recognized, and fail with error message. </p>
  
  <p>Do you have an idea or an answer to resolve this problem ? </p>
  
  <h2>Edit 1</h2>
  
  <p>I update the code with help of agisteel, it's ok, code running :)</p>
  
  <pre><code>import java.util.Random
  
  //////////
  // Main //
  
  //Implicit random for all classes and object
  implicit val aprng = new Random
  implicit val function: Random =&gt; Double = arpng =&gt; arpng.nextFloat
  
  abstract class GenericFactory 
  {
    def build = println("build")
  }
  
  implicit object Factory extends GenericFactory
  {
    def build = println("return factory")
  }
  
  class A (implicit rate: Random =&gt; Double, implicit val factory : GenericFactory) {
  
    //def this(rate : Double, factory : GenericFactory) = this( _ =&gt; rate, factory)
  
    def operate(genomes: IndexedSeq[Int])(implicit aprng: Random) = { 
      println("calculate genomes with aprng random values")}
  }
  
  object B{
  val instanceOfA = new A
  }
  </code></pre>