title: Runtime instantiation in scala without type parameters
body: <p>So here's what I have:</p>
  
  <pre><code>type CompType = Manifest[_ &lt;: Component]
  
  type EntityType = HashSet[CompType]
  type CompSet = HashSet[Component]
  
  val type_map = new HashMap[String, EntityType]
  val entity_map = new HashMap[EntityID, CompSet]
  
  def createEntityType(type_name: String) = {
    val ent_id = new EntityID
    val ent_type: CompSet =
      type_map(type_name) map (c_type =&gt; c_type.erasure.newInstance())
  
    entity_map += (ent_id -&gt; ent_type)
  
    ent_id
  }
  </code></pre>
  
  <p>But as you can see, the <code>map</code> function doesn't create a <code>CompSet</code>, it creates a <code>HashSet[Any]</code>.</p>
  
  <p>Is there any way of solving this problem?</p>
  
  <p>The whole point is to save object types for instantiation at a later time within the program, but I can't get this to work, and all the examples of reflection expect some kind of type parameter to cast to via <code>_.asInstanceOf[SomeClassType]</code>.</p>