Skip to content

Commit 0d607a7

Browse files
Nullability: RuntimeHelpers.GetHashCode should accept null obj input (#31819)
1 parent 5040afe commit 0d607a7

File tree

3 files changed

+4
-4
lines changed

3 files changed

+4
-4
lines changed

src/coreclr/src/System.Private.CoreLib/src/System/Runtime/CompilerServices/RuntimeHelpers.CoreCLR.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -107,7 +107,7 @@ public static void PrepareMethod(RuntimeMethodHandle method, RuntimeTypeHandle[]
107107
public static extern void PrepareDelegate(Delegate d);
108108

109109
[MethodImpl(MethodImplOptions.InternalCall)]
110-
public static extern int GetHashCode(object o);
110+
public static extern int GetHashCode(object? o);
111111

112112
[MethodImpl(MethodImplOptions.InternalCall)]
113113
public static extern new bool Equals(object? o1, object? o2);

src/libraries/System.Runtime/ref/System.Runtime.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7273,7 +7273,7 @@ public static partial class RuntimeHelpers
72737273
public static void EnsureSufficientExecutionStack() { }
72747274
public static new bool Equals(object? o1, object? o2) { throw null; }
72757275
public static void ExecuteCodeWithGuaranteedCleanup(System.Runtime.CompilerServices.RuntimeHelpers.TryCode code, System.Runtime.CompilerServices.RuntimeHelpers.CleanupCode backoutCode, object? userData) { }
7276-
public static int GetHashCode(object o) { throw null; }
7276+
public static int GetHashCode(object? o) { throw null; }
72777277
[return: System.Diagnostics.CodeAnalysis.NotNullIfNotNullAttribute("obj")]
72787278
public static object? GetObjectValue(object? obj) { throw null; }
72797279
public static T[] GetSubArray<T>(T[] array, System.Range range) { throw null; }

src/mono/netcore/System.Private.CoreLib/src/System/Runtime/CompilerServices/RuntimeHelpers.Mono.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -20,9 +20,9 @@ public static int OffsetToStringData {
2020
}
2121

2222
[MethodImplAttribute (MethodImplOptions.InternalCall)]
23-
static extern int InternalGetHashCode (object o);
23+
static extern int InternalGetHashCode (object? o);
2424

25-
public static int GetHashCode (object o)
25+
public static int GetHashCode (object? o)
2626
{
2727
return InternalGetHashCode (o);
2828
}

0 commit comments

Comments
 (0)