diff --git a/src/mono/mono/mini/jit-icalls.c b/src/mono/mono/mini/jit-icalls.c index 628d18abe35cf..24ec1b65dcf56 100644 --- a/src/mono/mono/mini/jit-icalls.c +++ b/src/mono/mono/mini/jit-icalls.c @@ -1482,7 +1482,8 @@ mono_gsharedvt_constrained_call (gpointer mp, MonoMethod *cmethod, MonoClass *kl g_assert (fsig->param_count < 16); memcpy (new_args, args, fsig->param_count * sizeof (gpointer)); for (int i = 0; i < fsig->param_count; ++i) { - if (deref_args [i]) + // If the argument is not a vtype or nullable, deref it + if (deref_args [i] && (deref_args [i] != MONO_GSHAREDVT_BOX_TYPE_VTYPE && deref_args [i] != MONO_GSHAREDVT_BOX_TYPE_NULLABLE)) new_args [i] = *(gpointer*)new_args [i]; } args = new_args; diff --git a/src/tests/JIT/Regression/JitBlue/Runtime_97625/Runtime_97625.cs b/src/tests/JIT/Regression/JitBlue/Runtime_97625/Runtime_97625.cs new file mode 100644 index 0000000000000..2a2ad6b87873a --- /dev/null +++ b/src/tests/JIT/Regression/JitBlue/Runtime_97625/Runtime_97625.cs @@ -0,0 +1,23 @@ +// Licensed to the .NET Foundation under one or more agreements. +// The .NET Foundation licenses this file to you under the MIT license. + +using System; +using System.Collections.Generic; +using System.Linq; +using Xunit; + +public static class Runtime_97625 +{ + public class CustomModel + { + public decimal Cost { get; set; } + } + + [Fact] + public static int Test() + { + List models = new List(); + models.Add(new CustomModel { Cost = 1 }); + return models.Average (x => x.Cost) == 1 ? 100 : -1; + } +} diff --git a/src/tests/JIT/Regression/JitBlue/Runtime_97625/Runtime_97625.csproj b/src/tests/JIT/Regression/JitBlue/Runtime_97625/Runtime_97625.csproj new file mode 100644 index 0000000000000..15edd99711a1a --- /dev/null +++ b/src/tests/JIT/Regression/JitBlue/Runtime_97625/Runtime_97625.csproj @@ -0,0 +1,8 @@ + + + True + + + + + \ No newline at end of file