Use cast<> instead which will assert that the cast is correct and not just return null. Fixes static analysis warnings.