Scala

Scala

Made by DeepSource

Comparing a fresh object with the result of getClass always evaluates to false SC-W1071

Bug risk
Critical

The new keyword allows you to instantiate a class where as the getClass method defined on an object returns Class[_ <: T] where the type T is an upperbound. Comparing both the values will always evaluate to false. Consider using an alternative such as the .isInstanceOf method instead.

Bad Practice

val eq = c.getClass == new C

Recommended

val eq = c.isInstanceOf[C]