Skip to content
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 5 additions & 5 deletions src/mono/mono/metadata/class.c
Original file line number Diff line number Diff line change
Expand Up @@ -4242,11 +4242,11 @@ mono_class_is_assignable_from_general (MonoClass *klass, MonoClass *oklass, gboo
}

if (m_class_get_byval_arg (klass)->type == MONO_TYPE_FNPTR) {
/*
* if both klass and oklass are fnptr, and they're equal, we would have returned at the
* beginning.
*/
/* Is this right? or do we need to look at signature compatibility? */
if (mono_metadata_signature_equal (klass_byval_arg->data.method, oklass_byval_arg->data.method)) {
*result = TRUE;
return;
}

*result = FALSE;
return;
}
Expand Down
2 changes: 1 addition & 1 deletion src/mono/mono/metadata/marshal.c
Original file line number Diff line number Diff line change
Expand Up @@ -4702,7 +4702,7 @@ get_virtual_stelemref_kind (MonoClass *element_class)
if (element_class == mono_defaults.object_class)
return STELEMREF_OBJECT;
if (is_monomorphic_array (element_class))
return STELEMREF_SEALED_CLASS;
return STELEMREF_COMPLEX;

/* magic ifaces requires aditional checks for when the element type is an array */
if (MONO_CLASS_IS_INTERFACE_INTERNAL (element_class) && m_class_is_array_special_interface (element_class))
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
using System;
using System.Runtime.InteropServices;

namespace TestFunctionPointer
{
unsafe class TestThings
{
public static delegate* managed<int>[][] Functions = {
new delegate* managed<int>[]
{
&Function,
},
};

public static int Function() => 100;

public static delegate* unmanaged<int>[][] Functions1 = {
new delegate* unmanaged<int>[]
{
&Function1,
},
};

[UnmanagedCallersOnly]
public static int Function1() => 100;

public static delegate* managed<int, int>[][] Functions2 = {
new delegate* managed<int, int>[]
{
&Function2,
},
};

public static int Function2(int a) {
return a;
}
}

unsafe class Program
{
public static int Main()
{
return TestThings.Functions2[0][0](TestThings.Functions[0][0]());
}
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<OutputType>Exe</OutputType>
<AllowUnsafeBlocks>true</AllowUnsafeBlocks>
</PropertyGroup>
<ItemGroup>
<Compile Include="Functionpointer.cs" />
</ItemGroup>
</Project>