diff --git a/csharp/ql/lib/qlpack.yml b/csharp/ql/lib/qlpack.yml index 92a08088be73..f8ee05e306f4 100644 --- a/csharp/ql/lib/qlpack.yml +++ b/csharp/ql/lib/qlpack.yml @@ -18,3 +18,4 @@ dataExtensions: - ext/*.model.yml - ext/generated/*.model.yml warnOnImplicitThis: true +compileForOverlayEval: true diff --git a/csharp/ql/lib/semmle/code/csharp/Conversion.qll b/csharp/ql/lib/semmle/code/csharp/Conversion.qll index 7a1314abe163..99c58ee51c68 100644 --- a/csharp/ql/lib/semmle/code/csharp/Conversion.qll +++ b/csharp/ql/lib/semmle/code/csharp/Conversion.qll @@ -719,6 +719,15 @@ private Type convTypeParameterBase(TypeParameter tp) { result = getATypeParameterFromConstraints+(tp) } +pragma[noinline] +private Class typeConstraintToBaseType(TypeParameterConstraints tpc) { + tpc.hasValueTypeConstraint() and result instanceof SystemValueTypeClass + or + result = tpc.getATypeConstraint() + or + tpc.hasRefTypeConstraint() and result instanceof ObjectType +} + /** * 10.1.5: Candidates for the effective base class of type parameter `tp`. * @@ -731,13 +740,9 @@ private Class effectiveBaseClassCandidate(TypeParameter tp) { not hasPrimaryConstraints(tp) and result instanceof ObjectType or exists(TypeParameterConstraints tpc | tpc = tp.getConstraints() | - tpc.hasValueTypeConstraint() and result instanceof SystemValueTypeClass - or - result = tpc.getATypeConstraint() + result = typeConstraintToBaseType(tpc) or result = effectiveBaseClassCandidate(tpc.getATypeConstraint()) - or - tpc.hasRefTypeConstraint() and result instanceof ObjectType ) }