[mini] fix static virtual constrained calls in non-generic interfaces (#65390)
authorAleksey Kliger (λgeek) <alklig@microsoft.com>
Wed, 16 Feb 2022 00:42:10 +0000 (19:42 -0500)
committerGitHub <noreply@github.com>
Wed, 16 Feb 2022 00:42:10 +0000 (19:42 -0500)
if the callee interface method is not generic, but the constained constraint
uses a generic var or mvar, do the indirect interface call.

fixes https://github.com/dotnet/runtime/issues/65384

src/mono/mono/mini/method-to-ir.c

index 3a6aed1..2043164 100644 (file)
@@ -7640,6 +7640,8 @@ mono_method_to_ir (MonoCompile *cfg, MonoMethod *method, MonoBasicBlock *start_b
                                MonoGenericContext *cmethod_context = mono_method_get_context (cmethod);
 
                                context_used = mini_method_check_context_used (cfg, cmethod);
+                               if (!context_used && gshared_static_virtual)
+                                       context_used = mini_class_check_context_used (cfg, constrained_class);
 
                                if (context_used && mono_class_is_interface (cmethod->klass) && !m_method_is_static (cmethod)) {
                                        /* Generic method interface