@@ -11008,17 +11008,25 @@ QualType Sema::DeduceTemplateSpecializationFromInitializer(
11008
11008
if (!Template) {
11009
11009
if (AliasTemplate = dyn_cast_or_null<TypeAliasTemplateDecl>(
11010
11010
TemplateName.getAsTemplateDecl ()); AliasTemplate) {
11011
- llvm::errs () << " alias template decl \n " ;
11012
- auto UnderlyingType = AliasTemplate->getTemplatedDecl ()
11011
+ // Unrap the sugar ElaboratedType.
11012
+ auto RhsType = AliasTemplate->getTemplatedDecl ()
11013
11013
->getUnderlyingType ()
11014
- .getDesugaredType (Context);
11014
+ .getSingleStepDesugaredType (Context);
11015
11015
if (const auto *TST =
11016
- UnderlyingType->getAs <TemplateSpecializationType>()) {
11017
- // normal cases: using AliasFoo = Foo<T, U>;
11016
+ RhsType->getAs <TemplateSpecializationType>()) {
11017
+ // The template decl in the TST can be a TypeALiasTemplateDecl if
11018
+ // the right hand side of the alias is a type alias as well. E.g.
11019
+ //
11020
+ // template<typename T>
11021
+ // using AliasFoo1 = Foo<T>; // Foo<T> is a class template specialization
11022
+ //
11023
+ // template<typename T>
11024
+ // using AliasFoo2 = AliasFoo1<T>; // AliasFoo1<T> is a type alias
11025
+ // FIXME: handle this case, we need to recursively perform deductions.
11018
11026
Template = dyn_cast_or_null<ClassTemplateDecl>(
11019
11027
TST->getTemplateName ().getAsTemplateDecl ());
11020
11028
AliasRhsTemplateArgs = TST->template_arguments ();
11021
- } else if (const auto *RT = UnderlyingType ->getAs <RecordType>()) {
11029
+ } else if (const auto *RT = RhsType ->getAs <RecordType>()) {
11022
11030
// cases where template arguments in the RHS of the alias are not
11023
11031
// dependent. e.g.
11024
11032
// using AliasFoo = Foo<bool>;
0 commit comments