implemented declaration#istype and __castto__ handler