Skip to content

Commit a36f07c

Browse files
thaystglewing
authored andcommitted
Fix DIM in a generic interface. Fixes #17869
1 parent 08e5a97 commit a36f07c

File tree

3 files changed

+37
-0
lines changed

3 files changed

+37
-0
lines changed

mono/metadata/class-init.c

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3029,6 +3029,8 @@ mono_class_setup_vtable_general (MonoClass *klass, MonoMethod **overrides, int o
30293029
for (int i = 0; i < iface_onum; i++) {
30303030
MonoMethod *decl = iface_overrides [i*2];
30313031
MonoMethod *override = iface_overrides [i*2 + 1];
3032+
if (mono_class_is_gtd (override->klass))
3033+
override = mono_class_inflate_generic_method_full_checked (override, ic, mono_class_get_context (ic), error);
30323034
if (decl->is_inflated) {
30333035
override = mono_class_inflate_generic_method_checked (override, mono_method_get_context (decl), error);
30343036
mono_error_assert_ok (error);

mono/tests/Makefile.am

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -384,6 +384,7 @@ TESTS_CS_SRC= \
384384
reflection.cs \
385385
interface.cs \
386386
interface-2.cs \
387+
dim-generic.cs \
387388
iface.cs \
388389
iface2.cs \
389390
iface3.cs \

mono/tests/dim-generic.cs

Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,34 @@
1+
using System;
2+
3+
4+
interface IBaseThingy
5+
{
6+
int Foo ();
7+
}
8+
9+
interface INativeThingy<T> : IBaseThingy
10+
{
11+
int IBaseThingy.Foo () {
12+
return 0;
13+
}
14+
}
15+
16+
class NativeThingy : INativeThingy<string>
17+
{
18+
}
19+
20+
public class Test
21+
{
22+
public static int test_0_dim_override()
23+
{
24+
var thingy = new NativeThingy ();
25+
var ithingy = (IBaseThingy)thingy;
26+
int i = ithingy.Foo ();
27+
return i;
28+
}
29+
30+
public static int Main (string[] args) {
31+
return TestDriver.RunTests (typeof (Test), args);
32+
}
33+
34+
}

0 commit comments

Comments
 (0)