File tree Expand file tree Collapse file tree 1 file changed +10
-5
lines changed
csharp/ql/lib/semmle/code/csharp Expand file tree Collapse file tree 1 file changed +10
-5
lines changed Original file line number Diff line number Diff line change @@ -719,6 +719,15 @@ private Type convTypeParameterBase(TypeParameter tp) {
719719 result = getATypeParameterFromConstraints + ( tp )
720720}
721721
722+ pragma [ noinline]
723+ private Class typeConstraintToBaseType ( TypeParameterConstraints tpc ) {
724+ tpc .hasValueTypeConstraint ( ) and result instanceof SystemValueTypeClass
725+ or
726+ result = tpc .getATypeConstraint ( )
727+ or
728+ tpc .hasRefTypeConstraint ( ) and result instanceof ObjectType
729+ }
730+
722731/**
723732 * 10.1.5: Candidates for the effective base class of type parameter `tp`.
724733 *
@@ -731,13 +740,9 @@ private Class effectiveBaseClassCandidate(TypeParameter tp) {
731740 not hasPrimaryConstraints ( tp ) and result instanceof ObjectType
732741 or
733742 exists ( TypeParameterConstraints tpc | tpc = tp .getConstraints ( ) |
734- tpc .hasValueTypeConstraint ( ) and result instanceof SystemValueTypeClass
735- or
736- result = tpc .getATypeConstraint ( )
743+ result = typeConstraintToBaseType ( tpc )
737744 or
738745 result = effectiveBaseClassCandidate ( tpc .getATypeConstraint ( ) )
739- or
740- tpc .hasRefTypeConstraint ( ) and result instanceof ObjectType
741746 )
742747}
743748
You can’t perform that action at this time.
0 commit comments