@@ -3812,26 +3812,35 @@ class cppfront
3812
3812
// -----------------------------------------------------------------------
3813
3813
// Else handle ordinary parameters
3814
3814
3815
- auto unqid = std::get_if<type_id_node::unqualified>(& type_id. id );
3815
+ auto param_type = print_to_string ( type_id);
3816
3816
3817
- // If this parameter's name is an unqualified-id, check to see
3818
- // if it's the name of one of the template parameters
3819
- auto is_template_parameter_name = false ;
3817
+ // If there are template parameters, see if this parameter's name is an
3818
+ // unqualified-id with a template parameter name, or mentions a template
3819
+ // parameter as a template argument
3820
+ auto is_dependent_parameter_type = false ;
3820
3821
if (
3821
- unqid
3822
- && current_declarations.back ()
3822
+ current_declarations.back ()
3823
3823
&& current_declarations.back ()->template_parameters
3824
3824
)
3825
3825
{
3826
3826
for (auto & tparam : current_declarations.back ()->template_parameters ->parameters )
3827
3827
{
3828
- assert (tparam);
3828
+ assert (
3829
+ tparam
3830
+ && tparam->name ()
3831
+ );
3832
+ // For now just do a quick string match
3833
+ auto tparam_name = tparam->name ()->to_string (true );
3829
3834
if (
3830
3835
tparam->declaration ->is_type ()
3831
- && tparam->declaration ->has_name ( *(*unqid)->identifier )
3836
+ && (
3837
+ param_type == tparam_name
3838
+ || std::string_view{param_type}.find (" <" +tparam_name) != std::string_view::npos
3839
+ || std::string_view{param_type}.find (" ," +tparam_name) != std::string_view::npos
3840
+ )
3832
3841
)
3833
3842
{
3834
- is_template_parameter_name = true ;
3843
+ is_dependent_parameter_type = true ;
3835
3844
}
3836
3845
}
3837
3846
}
@@ -3843,7 +3852,7 @@ class cppfront
3843
3852
if (
3844
3853
!is_returns
3845
3854
&& !type_id.is_wildcard ()
3846
- && !is_template_parameter_name
3855
+ && !is_dependent_parameter_type
3847
3856
)
3848
3857
{
3849
3858
switch (n.pass ) {
@@ -3857,12 +3866,12 @@ class cppfront
3857
3866
3858
3867
if (
3859
3868
type_id.is_wildcard ()
3860
- || is_template_parameter_name
3869
+ || is_dependent_parameter_type
3861
3870
)
3862
3871
{
3863
3872
auto name = std::string{" auto" };
3864
- if (is_template_parameter_name ) {
3865
- name = *(*unqid)-> identifier ;
3873
+ if (is_dependent_parameter_type ) {
3874
+ name = param_type ;
3866
3875
}
3867
3876
switch (n.pass ) {
3868
3877
break ;case passing_style::in : printer.print_cpp2 ( name+" const&" , n.position () );
@@ -3912,7 +3921,7 @@ class cppfront
3912
3921
if (
3913
3922
!is_returns
3914
3923
&& !type_id.is_wildcard ()
3915
- && !is_template_parameter_name
3924
+ && !is_dependent_parameter_type
3916
3925
)
3917
3926
{
3918
3927
switch (n.pass ) {
0 commit comments