@@ -39,6 +39,8 @@ class DispatchCall extends Internal::TDispatchCall {
3939
4040/** Internal implementation details. */
4141private module Internal {
42+ private import semmle.code.csharp.Implements
43+
4244 cached
4345 private module Cached {
4446 /** Internal representation of calls. */
@@ -656,45 +658,28 @@ private module Internal {
656658 or
657659 y instanceof TypeParameter
658660 or
659- // They must have the same kind.
660- (
661- x instanceof PointerType and y instanceof PointerType
662- or
663- x instanceof NullableType and y instanceof NullableType
664- or
665- x .( ArrayType ) .hasSameShapeAs ( y .( ArrayType ) )
666- or
667- x .( ConstructedType ) .getUnboundGeneric ( ) = y .( ConstructedType ) .getUnboundGeneric ( )
668- ) and
669- // All of their corresponding children must be structurally equal
661+ // All of the children must be structurally equal
670662 sameChildrenModuloTypeParameters ( x , y , x .getNumberOfChildren ( ) - 1 )
671663 )
672664 }
673665
666+ pragma [ noinline]
667+ private Type candidateInternalKind ( Type t , Gvn:: CompoundTypeKind k ) {
668+ result = candidateInternal ( t ) and
669+ k = Gvn:: getTypeKind ( t )
670+ }
671+
674672 /**
675673 * Holds if the `i+1` first children of types `x` and `y` are equal
676674 * modulo type parameters.
677675 */
676+ pragma [ nomagic]
678677 private predicate sameChildrenModuloTypeParameters ( Type x , Type y , int i ) {
679- exists ( Type xChild , Type yChild |
680- i = 0 and
681- candidateChildren ( x , i , xChild , yChild ) and
682- yChild = y .getChild ( i ) and
683- sameModuloTypeParameters ( xChild , yChild )
684- )
678+ i = - 1 and
679+ y = candidateInternalKind ( x , Gvn:: getTypeKind ( y ) )
685680 or
686- exists ( Type xChild , Type yChild | sameChildrenModuloTypeParameters ( x , y , i - 1 ) |
687- candidateChildren ( x , i , xChild , yChild ) and
688- yChild = y .getChild ( i ) and
689- sameModuloTypeParameters ( xChild , yChild )
690- )
691- }
692-
693- private predicate candidateChildren ( Type x , int i , Type xChild , Type yChild ) {
694- exists ( Type y | y = candidateInternal ( x ) |
695- xChild = x .getChild ( i ) and
696- yChild = y .getChild ( i )
697- )
681+ sameChildrenModuloTypeParameters ( x , y , i - 1 ) and
682+ sameModuloTypeParameters ( x .getChild ( i ) , y .getChild ( i ) )
698683 }
699684
700685 /**
0 commit comments