Relationship between instance of classes and its companion object
<p>I have the following class and companion object:</p>

<pre><code>class TestMatch(val i: Int)

object TestMatch{
  def apply(i: Int) = new TestMatch(i)
  def unapply(tm : TestMatch): Option[Int] = Some(tm.i)
}
</code></pre>

<p>Now consider the following simple program:</p>

<pre><code>println("isAssignableFrom: " + classOf[TestMatch].isAssignableFrom((tm.getClass)))
println("equality: " + classOf[TestMatch].equals((tm.getClass)))
println("instanceOf:" + TestMatch.isInstanceOf[TestMatch])
</code></pre>

<p>it prints:</p>

<pre><code>isAssignableFrom: true
equality: true
instanceOf:false
</code></pre>

<p>How is it possible? Have not come across with this in Java yet.</p>