Skip to content

Commit bae1adf

Browse files
authored
Merge pull request #1296 from Unity-Technologies/unity-master-fix-1235903
[runtime] Magic interfaces requires the complex stelemref to handle a…
2 parents 445cffc + 7cde13c commit bae1adf

File tree

2 files changed

+30
-0
lines changed

2 files changed

+30
-0
lines changed

mono/metadata/marshal.c

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9837,6 +9837,11 @@ get_virtual_stelemref_kind (MonoClass *element_class)
98379837
return STELEMREF_OBJECT;
98389838
if (is_monomorphic_array (element_class))
98399839
return STELEMREF_SEALED_CLASS;
9840+
9841+
/* magic ifaces requires aditional checks for when the element type is an array */
9842+
if (MONO_CLASS_IS_INTERFACE (element_class) && element_class->is_array_special_interface)
9843+
return STELEMREF_COMPLEX;
9844+
98409845
/* Compressed interface bitmaps require code that is quite complex, so don't optimize for it. */
98419846
if (MONO_CLASS_IS_INTERFACE (element_class) && !mono_class_has_variant_generic_params (element_class))
98429847
#ifdef COMPRESSED_INTERFACE_BITMAP

mono/mini/objects.cs

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
using System;
22
using System.Text;
33
using System.Reflection;
4+
using System.Collections.Generic;
45
using System.Runtime.InteropServices;
56
using System.Runtime.CompilerServices;
67

@@ -1829,6 +1830,30 @@ public static int test_0_typedref () {
18291830

18301831
return 0;
18311832
}
1833+
1834+
public interface IFoo
1835+
{
1836+
int MyInt { get; }
1837+
}
1838+
1839+
public class IFooImpl : IFoo
1840+
{
1841+
public int MyInt => 0;
1842+
}
1843+
1844+
//gh 6266
1845+
public static int test_0_store_to_magic_iface_array ()
1846+
{
1847+
ICollection<IFoo> arr1 = new IFooImpl[1] { new IFooImpl() };
1848+
ICollection<IFoo> arr2 = new IFooImpl[1] { new IFooImpl() };
1849+
1850+
ICollection<IFoo>[] a2d = new ICollection<IFoo>[2] {
1851+
arr1,
1852+
arr2,
1853+
};
1854+
1855+
return 0;
1856+
}
18321857
}
18331858

18341859
#if __MOBILE__

0 commit comments

Comments
 (0)