In each example, you do not mean the same concept TestMatch.
classOf[TestMatch]and instanceOf[TestMatch]are referred to TestMatchas type. Singletones do not define type.TestMatch.something() - method call for singleton object TestMatch
Now, which can be a little confusing, the following:
object Singleton
println(Singleton.isInstanceOf[Singleton])
I assume Scala gives priority to the class when singleton is an object companion.
Edit:
, scala.Singleton SDK Scala, ... :
object MySingleton
println(MySingleton.isInstanceOf[MySingleton])
, singleton . .
println(MySingleton.isInstanceOf[MySingleton.type]) // true
, , .
class MyClassWithCompanion
object MyClassWithCompanion
val x = new MyClassWithCompanion
println(MyClassWithCompanion.isInstanceOf[MyClassWithCompanion]) // false
println(MyClassWithCompanion.isInstanceOf[MyClassWithCompanion.type]) // true
println(MyClassWithCompanion.isInstanceOf[x.type] // false
, :
.type - ,x.type , x -, MyClass.type , -. MyClassWithCompanion.type - ( ),- .
x singleton x, , .