Type parameters can be referred from e.g. function return type, so we should determine them earlier to be able to set their indexes