@@ -137,9 +137,7 @@ public static bool HasRefBase(this Class @class)
137
137
if ( @class . HasBaseClass )
138
138
@base = @class . Bases [ 0 ] . Class ;
139
139
140
- var hasRefBase = @base != null && @base . IsRefType && @base . IsGenerated ;
141
-
142
- return hasRefBase ;
140
+ return @base ? . IsRefType == true && @base . IsGenerated ;
143
141
}
144
142
145
143
public static IEnumerable < TranslationUnit > GetGenerated ( this IEnumerable < TranslationUnit > units )
@@ -150,8 +148,7 @@ public static IEnumerable<TranslationUnit> GetGenerated(this IEnumerable<Transla
150
148
public static List < ClassTemplateSpecialization > GetSpecializationsToGenerate (
151
149
this Class classTemplate )
152
150
{
153
- if ( classTemplate . Fields . Any (
154
- f => f . Type . Desugar ( ) is TemplateParameterType ) )
151
+ if ( classTemplate . HasDependentValueFieldInLayout ( ) )
155
152
return classTemplate . Specializations ;
156
153
157
154
var specializations = new List < ClassTemplateSpecialization > ( ) ;
@@ -162,5 +159,30 @@ public static List<ClassTemplateSpecialization> GetSpecializationsToGenerate(
162
159
specializations . Add ( specialization ) ;
163
160
return specializations ;
164
161
}
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
+ }
165
187
}
166
188
}
0 commit comments