@@ -11008,17 +11008,25 @@ QualType Sema::DeduceTemplateSpecializationFromInitializer(
1100811008 if (!Template) {
1100911009 if (AliasTemplate = dyn_cast_or_null<TypeAliasTemplateDecl>(
1101011010 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 ()
1101311013 ->getUnderlyingType ()
11014- .getDesugaredType (Context);
11014+ .getSingleStepDesugaredType (Context);
1101511015 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.
1101811026 Template = dyn_cast_or_null<ClassTemplateDecl>(
1101911027 TST->getTemplateName ().getAsTemplateDecl ());
1102011028 AliasRhsTemplateArgs = TST->template_arguments ();
11021- } else if (const auto *RT = UnderlyingType ->getAs <RecordType>()) {
11029+ } else if (const auto *RT = RhsType ->getAs <RecordType>()) {
1102211030 // cases where template arguments in the RHS of the alias are not
1102311031 // dependent. e.g.
1102411032 // using AliasFoo = Foo<bool>;
0 commit comments