Fix takeType to deal with inheritance