title: D mixin with factory
body: <p>Consider I have the following classes:</p>
  
  <pre><code>/// File classes.d
  class C {
      string type() { return "C"; };
  }
  
  class C1 : C {
      override string type() { return "C1"; };
  }
  
  class C2 : C {
      override string type() { return "C1"; };
  }
  </code></pre>
  
  <p>Now I want to implement a factory somewhere else, like:</p>
  
  <pre><code>/// File factory.d
  module factory;
  import std.functional;
  import std.stdio;
  
  void main() {
      mixin(import("classes.d"));
      auto c = cast(typeof(mixin("C1"))) Object.factory("C1");
      writeln(c.type());
  }
  </code></pre>
  
  <p>The compiler (dmd 2.058) says me:</p>
  
  <pre><code>factory.d(7): Error argument C1 to typeof is not an expression
  </code></pre>
  
  <p>I know the following line compiles well:</p>
  
  <pre><code>auto c = cast(C1) Object.factory("classes.C1");
  </code></pre>
  
  <p>but this requires me to know the type (C1) at compile time. I want to get the type at runtime (like a string).</p>