Skip to content

Commit 0343727

Browse files
committed
C#: Fix bad join due to overlay compilation.
1 parent 8b65cb0 commit 0343727

File tree

1 file changed

+10
-5
lines changed

1 file changed

+10
-5
lines changed

csharp/ql/lib/semmle/code/csharp/Conversion.qll

Lines changed: 10 additions & 5 deletions
Original file line numberDiff line numberDiff 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

0 commit comments

Comments
 (0)