title: Scala wont pattern match with java.lang.String and Case Class
body: <p>Hello fellow Scala Programmers</p>
  
  <p>I have been working with Scala for some month now, however I have a problem with some properly basic stuff, I am hoping you will help my out with it.</p>
  
  <pre><code>case class PersonClass(name: String, age: Int)
  
  object CaseTester {
  def main(args:Array[String])
   {
    val string = "hej"
    string match {
      case e:String =&gt; println(string)
      case PersonClass =&gt; println(string)
    }
   }
  }
  </code></pre>
  
  <p>When I am doing like this I get error:</p>
  
  <pre><code>pattern type is incompatible with expected type;
  found   : object PersonClass
  required: java.lang.String
  case PersonClass =&gt; println(string)
  </code></pre>
  
  <p>And if I then change the second line in the pattern matching to the following:</p>
  
  <pre><code>case e:PersonClass =&gt; println(string)
  </code></pre>
  
  <p>I then get the error:</p>
  
  <pre><code>error: scrutinee is incompatible with pattern type;
  found   : PersonClass
  required: java.lang.String
  case e:PersonClass =&gt; println(string)
  </code></pre>
  
  <p>However if I change the string definition to the following it compiles fine in both cases.</p>
  
  <pre><code>val string:AnyRef = "hej"
  </code></pre>