rewrote TypeResolver with visitor pattern