Sealed class with object subclass: 'when' cannot smart cast object?

That makes sense from the JVM point of view. However, the Kotlin compiler could, in theory, understand that it’s dealing with the object here. How could it refer to anything else at this point? It’s a val and its equals method returns true for the object. Doesn’t it violate the language specification if it then doesn’t behave like the equal object? It has to be of the same type. If it’s not, even if the equals method (or == operator) is overridden in some strange way to return true for our object (see example below), then still the compiler doesn’t allow to compare them due to different types.

For example (shortened for brevity, does not compile due to different types around ==):

object Baz {
  val name = "Baz"
}

class NotBaz {
	override fun equals(other: Any?): Boolean = other is Baz // Or simply always return true
}

val notBaz = NotBaz()
val name = if (notBaz == Baz) Baz.name else "" // Error: Operator '==' cannot be applied to 'NotBaz' and 'Baz'
println(name)

I know it’s all strange to use type checks, equality checks and objects like this, but I’m wondering if the compiler truly cannot conclude more than it does right now.