Why can't Kotlin infer the type in this example?
In the following example the compiler figures out that because of the object identity check of b1.a to b2.a that they must have the same type. However, it can't seem to figure out that because of b1.a having type A b1.t must have type T2.
class A
class B(val t: T, val a: A)
fun foo(b1: B, b2: B) {
if (b1.a !== b2.a) return
val otherA: A = b1.a // smart cast
val otherT: T2 = b1.t // type mismatch error
b1.a as A // useless cast
b1 as B // unchecked cast warning
}