Fix handling of non-beforefieldinit interface cctors (#86311)
authorMichal Strehovský <MichalStrehovsky@users.noreply.github.com>
Tue, 16 May 2023 17:37:09 +0000 (02:37 +0900)
committerGitHub <noreply@github.com>
Tue, 16 May 2023 17:37:09 +0000 (10:37 -0700)
Scanner would miss them. These trigger the same way as valuetype methods (instance methods will trigger them).

src/coreclr/tools/aot/ILCompiler.Compiler/IL/ILImporter.Scanner.cs

index 9e00383..6757a33 100644 (file)
@@ -118,7 +118,7 @@ namespace Internal.IL
                 // Don't trigger cctor if this is a fallback compilation (bad cctor could have been the reason for fallback).
                 // Otherwise follow the rules from ECMA-335 I.8.9.5.
                 if (!_isFallbackBodyCompilation &&
-                    (_canonMethod.Signature.IsStatic || _canonMethod.IsConstructor || owningType.IsValueType))
+                    (_canonMethod.Signature.IsStatic || _canonMethod.IsConstructor || owningType.IsValueType || owningType.IsInterface))
                 {
                     // For beforefieldinit, we can wait for field access.
                     if (!((MetadataType)owningType).IsBeforeFieldInit)