[PLAT-6349] Check instance before cast