@@ -118,17 +118,16 @@ private void AddTemplateSpecializedArguments(List<CppTemplateArgument> sourceArg
118118 }
119119 else
120120 {
121- /* This is quite impossible, just to make sure */
122- if ( existingParams . Count ( ) > 1 )
121+ /** Don't really know what to do with the case if we have the same template parameter multiple times */
122+ if ( existingParams . Count ( ) == 1 )
123123 {
124- throw new InvalidOperationException ( $ "The same template parameter `{ p . SourceParam . FullName } ` exists more than one times") ;
125- }
126- var existingParam = existingParams [ 0 ] ;
127- if ( ! existingParam . IsSpecializedArgument && p . IsSpecializedArgument )
128- {
129- /* We need to replace the already existing non-specialized parameter with the new specialized one */
130- var index = destinationArguments . IndexOf ( existingParam ) ;
131- destinationArguments [ index ] = p ;
124+ var existingParam = existingParams [ 0 ] ;
125+ if ( ! existingParam . IsSpecializedArgument && p . IsSpecializedArgument )
126+ {
127+ /* We need to replace the already existing non-specialized parameter with the new specialized one */
128+ var index = destinationArguments . IndexOf ( existingParam ) ;
129+ destinationArguments [ index ] = p ;
130+ }
132131 }
133132 }
134133 }
@@ -142,6 +141,22 @@ private void UpdateTemplateType(CppClass cppClass)
142141 if ( cppClass . TemplateKind == CppTemplateKind . TemplateClass && cppClass . TemplateParameters . Count > 0 && cppClass . TemplateSpecializedArguments . Count > 0 )
143142 {
144143 cppClass . TemplateKind = CppTemplateKind . PartialTemplateClass ;
144+ /** We need to set the primary template */
145+ if ( cppClass . PrimaryTemplate == null && cppClass . BaseTypes . Count > 0 )
146+ {
147+ foreach ( var b in cppClass . BaseTypes )
148+ {
149+ if ( b . Type is CppClass )
150+ {
151+ var clz = b . Type as CppClass ;
152+ if ( clz . TemplateKind == CppTemplateKind . TemplateClass )
153+ {
154+ cppClass . PrimaryTemplate = clz ;
155+ break ;
156+ }
157+ }
158+ }
159+ }
145160 }
146161 }
147162
@@ -265,7 +280,6 @@ private CppContainerContext GetOrCreateDeclarationContainer(CXCursor cursor, voi
265280 Debug . Assert ( cppClass . PrimaryTemplate . TemplateParameters . Count == tempArgsCount ) ;
266281 }
267282
268-
269283 for ( uint i = 0 ; i < tempArgsCount ; i ++ )
270284 {
271285 var arg = cursor . GetTemplateArgument ( i ) ;
0 commit comments