Merge pull request #819 from brendanzagaeski/patch-1
[mono.git] / mcs / class / corlib / System / Nullable.cs
index b8ac671d69978cf8fbb0eb06db8344be9e803a99..11f6c67dbd4e4d73c69b0a3b4a007025069ea7bd 100644 (file)
@@ -74,10 +74,9 @@ namespace System
                {
                        if (nullableType == null)
                                throw new ArgumentNullException ("nullableType");
-                       if (nullableType.IsGenericType && nullableType.GetGenericTypeDefinition () == typeof (Nullable<>))
-                               return nullableType.GetGenericArguments ()[0];
-                       else
-                               return null;
+
+                       return nullableType.IsGenericType && !nullableType.IsGenericTypeDefinition && nullableType.GetGenericTypeDefinition () == typeof(Nullable<>) ?
+                               nullableType.GetGenericArguments () [0] : null;
                }
        }
 
@@ -140,7 +139,7 @@ namespace System
 
                public T GetValueOrDefault ()
                {
-                       return has_value ? value : default (T);
+                       return value;
                }
 
                public T GetValueOrDefault (T defaultValue)