title: Error: found : AnyVal required: Int, how to do auto type casting in Scala
body: <p>I am getting following error message:</p>
  
  <pre><code>[error]  found   : AnyVal
  [error]  required: Int
  </code></pre>
  
  <p>But <code>Int</code> extends <code>AnyVal [1]</code> so I believe as in <code>Java</code>, <code>Integer</code> can be casted from <code>Object</code> why it's not working in <code>Scala</code>, what I am missing:</p>
  
  <pre><code>[1] final abstract class Int private extends AnyVal
  </code></pre>
  
  <p>I also tried with a simple example:</p>
  
  <pre><code>val a: AnyVal = 5
  
  def aTob(a: Int): Int = a * 5
  
  aTob(a)
  </code></pre>
  
  <blockquote>
    <p>Error:(5, 73) type mismatch;</p>
    
    <p>found : AnyVal</p>
    
    <p>required: Int</p>
  </blockquote>
  
  <p>But following works:</p>
  
  <pre><code>val a: Any = 5
  
  def aTob(a: Int): Int = a * 5
  
  aTob(a.asInstanceOf[Int])
  </code></pre>
  
  <p>I don't want to explicitly cast it, but it should be implicit casting.</p>
  
  <blockquote>
    <p>[Edit:] I also tried with <code>Any</code></p>
  </blockquote>
  
  <p>-</p>
  
  <blockquote>
    <p>Update: </p>
  </blockquote>
  
  <pre><code>def getValue(dType: String): Any = {
  
      dType.toLowerCase() match {
  
          case "double[3]" =&gt;
              10d
          case "float" =&gt;
              1f
  
  }
  
  val d = getValue("double[3]")
  val f = getValue("float")
  
  SomeClass(d, f)
  
  
  case class SomeClass(val d : Double, val f: Float)
  </code></pre>