Remove redundant UnderlyingSystemType calls (#24000)
authorJan Kotas <jkotas@microsoft.com>
Mon, 15 Apr 2019 23:29:41 +0000 (16:29 -0700)
committerGitHub <noreply@github.com>
Mon, 15 Apr 2019 23:29:41 +0000 (16:29 -0700)
UnderlyingSystemType is virtual

src/System.Private.CoreLib/shared/System/Type.cs

index 8b19fbc..d2a31cb 100644 (file)
@@ -281,8 +281,9 @@ namespace System
         }
         protected virtual TypeCode GetTypeCodeImpl()
         {
-            if (this != UnderlyingSystemType && UnderlyingSystemType != null)
-                return Type.GetTypeCode(UnderlyingSystemType);
+            Type systemType = UnderlyingSystemType;
+            if (this != systemType && systemType != null)
+                return Type.GetTypeCode(systemType);
 
             return TypeCode.Object;
         }