Skip to content

Commit

Permalink
[interp] Fix open delegates used with virtual methods of valuetypes (#…
Browse files Browse the repository at this point in the history
…55354)

* [interp] Fix open delegates used with virtual methods of valuetypes

We were trying to resolve the virtual method on the this pointer (which is a managed pointer and not an object). If the delegate target method is declared on a valuetype, the method does not need resolving.

Fixes #49839

* Re-enable tests
  • Loading branch information
BrzVlad authored Jul 10, 2021
1 parent 5e65771 commit 1ff0b50
Show file tree
Hide file tree
Showing 2 changed files with 1 addition and 3 deletions.
2 changes: 0 additions & 2 deletions src/libraries/System.Runtime/tests/System/DelegateTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -1118,7 +1118,6 @@ public static void CreateDelegate9_Type_Null()
Assert.NotNull(ex.Message);
}

[ActiveIssue("https://github.com/dotnet/runtime/issues/49839", TestRuntimes.Mono)]
[Fact]
public static void CreateDelegate10_Nullable_Method()
{
Expand All @@ -1130,7 +1129,6 @@ public static void CreateDelegate10_Nullable_Method()
Assert.Equal(num.ToString(), s);
}

[ActiveIssue("https://github.com/dotnet/runtime/issues/49839", TestRuntimes.Mono)]
[Fact]
public static void CreateDelegate10_Nullable_ClosedDelegate()
{
Expand Down
2 changes: 1 addition & 1 deletion src/mono/mono/mini/interp/interp.c
Original file line number Diff line number Diff line change
Expand Up @@ -3437,7 +3437,7 @@ interp_exec_method (InterpFrame *frame, ThreadContext *context, FrameClauseArgs
del_imethod = mono_interp_get_imethod (mono_marshal_get_native_wrapper (del_imethod->method, FALSE, FALSE), error);
mono_error_assert_ok (error);
del->interp_invoke_impl = del_imethod;
} else if (del_imethod->method->flags & METHOD_ATTRIBUTE_VIRTUAL && !del->target) {
} else if (del_imethod->method->flags & METHOD_ATTRIBUTE_VIRTUAL && !del->target && !m_class_is_valuetype (del_imethod->method->klass)) {
// 'this' is passed dynamically, we need to recompute the target method
// with each call
del_imethod = get_virtual_method (del_imethod, LOCAL_VAR (call_args_offset + MINT_STACK_SLOT_SIZE, MonoObject*)->vtable);
Expand Down

0 comments on commit 1ff0b50

Please sign in to comment.