未验证 提交 d6c2b438 编写于 作者: F Fan Yang 提交者: GitHub

[Mono] Fix function pointer check (#80855)

* Fix function pointer check

* Make is_monomorphic_array return false when the element is function pointer

* Move test to a better location
上级 0ca36476
......@@ -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;
}
......
......@@ -4693,6 +4693,8 @@ is_monomorphic_array (MonoClass *klass)
return FALSE;
element_class = m_class_get_element_class (klass);
if (m_class_get_byval_arg (element_class)->type == MONO_TYPE_FNPTR)
return FALSE;
return mono_class_is_sealed (element_class) || m_class_is_valuetype (element_class);
}
......
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]());
}
}
}
\ No newline at end of file
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<OutputType>Exe</OutputType>
<AllowUnsafeBlocks>true</AllowUnsafeBlocks>
</PropertyGroup>
<ItemGroup>
<Compile Include="Functionpointer.cs" />
</ItemGroup>
</Project>
\ No newline at end of file
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册