Handle the case that the child template and the parent template have the same name (see #6939)