title: Generating a Scala class automatically from a trait
body: <p>I want to create a method that generates an implementation of a trait. For example:</p>
  
  <pre><code>trait Foo {
    def a
    def b(i:Int):String
  }
  
  object Processor {
    def exec(instance: AnyRef, method: String, params: AnyRef*) = {
      //whatever
    }
  }
  
  class Bar {
    def wrap[T] = {
      // Here create a new instance of the implementing class, i.e. if T is Foo,
      // generate a new FooImpl(this)
    }
  }
  </code></pre>
  
  <p>I would like to dynamically generate the <code>FooImpl</code> class like so:</p>
  
  <pre><code>class FooImpl(val wrapped:AnyRef) extends Foo {
    def a = Processor.exec(wrapped, "a")
    def b(i:Int) = Processor.exec(wrapped, "b", i)
  }
  </code></pre>
  
  <p>Manually implementing each of the traits is not something we would like (lots of boilerplate) so I'd like to be able to generate the Impl classes at compile time. I was thinking of annotating the classes and perhaps writing a compiler plugin, but perhaps there's an easier way? Any pointers will be appreciated.</p>