@@ -137,9 +137,7 @@ public static bool HasRefBase(this Class @class)
137137 if ( @class . HasBaseClass )
138138 @base = @class . Bases [ 0 ] . Class ;
139139
140- var hasRefBase = @base != null && @base . IsRefType && @base . IsGenerated ;
141-
142- return hasRefBase ;
140+ return @base ? . IsRefType == true && @base . IsGenerated ;
143141 }
144142
145143 public static IEnumerable < TranslationUnit > GetGenerated ( this IEnumerable < TranslationUnit > units )
@@ -150,8 +148,7 @@ public static IEnumerable<TranslationUnit> GetGenerated(this IEnumerable<Transla
150148 public static List < ClassTemplateSpecialization > GetSpecializationsToGenerate (
151149 this Class classTemplate )
152150 {
153- if ( classTemplate . Fields . Any (
154- f => f . Type . Desugar ( ) is TemplateParameterType ) )
151+ if ( classTemplate . HasDependentValueFieldInLayout ( ) )
155152 return classTemplate . Specializations ;
156153
157154 var specializations = new List < ClassTemplateSpecialization > ( ) ;
@@ -162,5 +159,30 @@ public static List<ClassTemplateSpecialization> GetSpecializationsToGenerate(
162159 specializations . Add ( specialization ) ;
163160 return specializations ;
164161 }
162+
163+ public static bool HasDependentValueFieldInLayout ( this Class @class )
164+ {
165+ if ( @class . Fields . Any ( f => IsValueDependent ( f . Type ) ) )
166+ return true ;
167+
168+ return @class . Bases . Where ( b => b . IsClass ) . Select (
169+ b => b . Class ) . Any ( HasDependentValueFieldInLayout ) ;
170+ }
171+
172+ private static bool IsValueDependent ( Type type )
173+ {
174+ var desugared = type . Desugar ( ) ;
175+ if ( desugared is TemplateParameterType )
176+ return true ;
177+ var tagType = desugared as TagType ;
178+ if ( tagType ? . IsDependent == true )
179+ return true ;
180+ var templateType = desugared as TemplateSpecializationType ;
181+ if ( templateType ? . Arguments . Any (
182+ a => a . Type . Type ? . Desugar ( ) . IsDependent == true ) == true )
183+ return true ;
184+ var arrayType = desugared as ArrayType ;
185+ return arrayType != null && IsValueDependent ( arrayType . Type ) ;
186+ }
165187 }
166188}
0 commit comments