From bf43d708b06449738ab11d620db0c4487ced48e2 Mon Sep 17 00:00:00 2001 From: David Wrighton Date: Tue, 11 May 2021 14:57:42 -0700 Subject: [PATCH] Fix variance safety check --- src/coreclr/vm/methodtablebuilder.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/coreclr/vm/methodtablebuilder.cpp b/src/coreclr/vm/methodtablebuilder.cpp index 7ae3a4c0181a59..ffa1d35155a6b3 100644 --- a/src/coreclr/vm/methodtablebuilder.cpp +++ b/src/coreclr/vm/methodtablebuilder.cpp @@ -3035,8 +3035,8 @@ MethodTableBuilder::EnumerateClassMethods() // Check the appearance of covariant and contravariant in the method signature // Note that variance is only supported for interfaces, and these rules are not - // checked for static methods as they cannot be called variantly. - if ((bmtGenerics->pVarianceInfo != NULL) && !IsMdStatic(dwMemberAttrs)) + // checked for non-virtual static methods as they cannot be called variantly. + if ((bmtGenerics->pVarianceInfo != NULL) && (IsMdVirtual(dwMemberAttrs) || !IsMdStatic(dwMemberAttrs))) { SigPointer sp(pMemberSignature, cMemberSignature); uint32_t callConv;