Fix infinite loop in hasSuperclass