Fix validation of uninstantiated generic methods (#2137)
authorMichal Strehovský <MichalStrehovsky@users.noreply.github.com>
Fri, 24 Jan 2020 20:56:32 +0000 (21:56 +0100)
committerGitHub <noreply@github.com>
Fri, 24 Jan 2020 20:56:32 +0000 (21:56 +0100)
Matches what we do for uninstatiated generic types - no need to look at generic parameters.

src/coreclr/src/tools/Common/Compiler/CompilerTypeSystemContext.Validation.cs

index a84ad55..6b9e863 100644 (file)
@@ -25,7 +25,9 @@ namespace ILCompiler
         {
             EnsureLoadableType(method.OwningType);
 
-            if (method.HasInstantiation)
+            // If this is an instantiated generic method, check the instantiation.
+            MethodDesc methodDef = method.GetMethodDefinition();
+            if (methodDef != method)
             {
                 foreach (var instType in method.Instantiation)
                     EnsureLoadableType(instType);
@@ -102,12 +104,6 @@ namespace ILCompiler
             {
                 ThrowHelper.ThrowTypeLoadException(ExceptionStringID.ClassLoadGeneral, type);
             }
-#if READYTORUN
-            else if (type.IsGenericParameter)
-            {
-                return type;
-            }
-#endif
             else
             {
                 // Validate classes, structs, enums, interfaces, and delegates