Two similar bugs were filed, both captured in GH62362. The problem
happens when collecting the instantiation args for a constructor with a
constraint is inherited by a child class.
When the inheriting class itself was NOT a template, the implicit
constructor that modeled the inherited constructor is in the declaration
context of the inherited type, however it is marked as implicit and as
an inheriting constructor. In order to make sure we get the correct
instantiation args, this patch recognizes this pattern, and causes us to
pick up the instantiation args from the inherited constructor. This
also corrects the 'declaration context' to be the
ClassTemplateSpecializationDecl of the inherited class, which has the
correct instantiation args.
however, if the inheriting class is already a template, the correct
constructor is actually already picked up, in the correct specialization
of the parent class. However, in the case of an explicit
specialization, we were skipping the template instantiation args. I
found that removing this early-return here actually broke no lit tests,
however I still limited the removal of this early return to concept
checks.
Fixes: #62362
It seems to me that a namespace-scope explicit specialization shouldn't pick up template arguments, even during constraint checking:
Constraint checking for A<X>::f<Y> should produce a single level of template arguments, <Y>, not two layers <X>, <Y>, because U in U::value is a depth-0 index-0 parameter.