Skip to content

Commit 7648815

Browse files
authored
Merge pull request #6936 from hvitved/csharp/delegate-conversion-join-order
C#: Improve join-order in `defaultDelegateConversion`
2 parents 12e56ec + 4e40337 commit 7648815

File tree

1 file changed

+6
-1
lines changed

1 file changed

+6
-1
lines changed

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

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -552,11 +552,16 @@ private predicate defaultDynamicConversion(Type fromType, Type toType) {
552552
fromType instanceof RefType and toType instanceof DynamicType
553553
}
554554

555+
pragma[noinline]
556+
private predicate systemDelegateBaseType(RefType t) {
557+
t = any(SystemDelegateClass c).getABaseType*()
558+
}
559+
555560
// This is a deliberate, small cartesian product, so we have manually lifted it to force the
556561
// evaluator to evaluate it in its entirety, rather than trying to optimize it in context.
557562
pragma[noinline]
558563
private predicate defaultDelegateConversion(RefType fromType, RefType toType) {
559-
fromType instanceof DelegateType and toType = any(SystemDelegateClass c).getABaseType*()
564+
fromType instanceof DelegateType and systemDelegateBaseType(toType)
560565
}
561566

562567
private predicate convRefTypeRefType(RefType fromType, RefType toType) {

0 commit comments

Comments
 (0)