Smart cast to ‘Type’ is impossible, because ‘variable’ is a mutable property that could have been changed by this time
Between execution of left != null and queue.add(left) another thread could have changed the value of left to null. To work around this you have several options. Here are some: Use a local variable with smart cast: val node = left if (node != null) { queue.add(node) } Use a safe call such as one … Read more