@@ -434,18 +434,30 @@ private predicate elementSpec(
434434 summaryModel ( namespace , type , subtypes , name , signature , ext , _, _, _, _, _)
435435}
436436
437+ private predicate isClassConstructedFrom ( Class c , Class templateClass ) {
438+ c .isConstructedFrom ( templateClass )
439+ or
440+ not any ( Class c_ ) .isConstructedFrom ( templateClass ) and c = templateClass
441+ }
442+
443+ private predicate isFunctionConstructedFrom ( Function f , Function templateFunc ) {
444+ f .isConstructedFrom ( templateFunc )
445+ or
446+ not any ( Function f_ ) .isConstructedFrom ( templateFunc ) and f = templateFunc
447+ }
448+
437449/** Gets the fully templated version of `f`. */
438450private Function getFullyTemplatedFunction ( Function f ) {
439451 not f .isFromUninstantiatedTemplate ( _) and
440452 (
441453 exists ( Class c , Class templateClass , int i |
442- c . isConstructedFrom ( templateClass ) and
454+ isClassConstructedFrom ( c , templateClass ) and
443455 f = c .getAMember ( i ) and
444456 result = templateClass .getCanonicalMember ( i )
445457 )
446458 or
447459 not exists ( f .getDeclaringType ( ) ) and
448- f . isConstructedFrom ( result )
460+ isFunctionConstructedFrom ( f , result )
449461 )
450462}
451463
@@ -489,7 +501,7 @@ private string getTypeNameWithoutFunctionTemplates(Function f, int n, int remain
489501private string getTypeNameWithoutClassTemplates ( Function f , int n , int remaining ) {
490502 // If there is a declaring type then we start by expanding the function templates
491503 exists ( Class template |
492- f .getDeclaringType ( ) . isConstructedFrom ( template ) and
504+ isClassConstructedFrom ( f .getDeclaringType ( ) , template ) and
493505 remaining = template .getNumberOfTemplateArguments ( ) and
494506 result = getTypeNameWithoutFunctionTemplates ( f , n , 0 )
495507 )
@@ -501,7 +513,7 @@ private string getTypeNameWithoutClassTemplates(Function f, int n, int remaining
501513 or
502514 exists ( string mid , TemplateParameter tp , Class template |
503515 mid = getTypeNameWithoutClassTemplates ( f , n , remaining + 1 ) and
504- f .getDeclaringType ( ) . isConstructedFrom ( template ) and
516+ isClassConstructedFrom ( f .getDeclaringType ( ) , template ) and
505517 tp = template .getTemplateArgument ( remaining ) and
506518 result = mid .replaceAll ( tp .getName ( ) , "class:" + remaining .toString ( ) )
507519 )
0 commit comments