@yole I agree with
@svd that this smart cast behaviour with local variables is unexpected (and surprising). According to all explanations of smart cast (including yours), smart cast is equivalent to casting the instance
right after the if
. This behaviour contradicts that.