Fix R2R issue with virtual method resolving to non-generic base (#11289)
authorYi Zhang (CLR) <yizhang82@users.noreply.github.com>
Fri, 28 Apr 2017 15:41:29 +0000 (08:41 -0700)
committerJan Kotas <jkotas@microsoft.com>
Fri, 28 Apr 2017 15:41:29 +0000 (08:41 -0700)
src/vm/compile.cpp

index 9161585..76a4147 100644 (file)
@@ -1723,6 +1723,12 @@ mdToken CEECompileInfo::TryEncodeMethodAsToken(
         if (!pReferencingModule->IsInCurrentVersionBubble())
             return mdTokenNil;
 
+        // If this is a MemberRef with TypeSpec, we might come to here because we resolved the method
+        // into a non-generic base class in the same version bubble. However, since we don't have the
+        // proper type context during ExternalMethodFixupWorker, we can't really encode using token
+        if (pResolvedToken->pTypeSpec != NULL)
+            return mdTokenNil;
+            
         unsigned methodToken = pResolvedToken->token;
 
         switch (TypeFromToken(methodToken))