Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
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
54 changes: 45 additions & 9 deletions src/mono/mono/metadata/icall.c
Original file line number Diff line number Diff line change
Expand Up @@ -2535,10 +2535,36 @@ set_interface_map_data_method_object (MonoMethod *method, MonoClass *iclass, int

MONO_HANDLE_ARRAY_SETREF (methods, i, member);

MONO_HANDLE_ASSIGN (member, mono_method_get_object_handle (m_class_get_vtable (klass) [i + ioffset], klass, error));
goto_if_nok (error, leave);
MonoMethod* foundMethod = m_class_get_vtable (klass) [i + ioffset];

if (mono_class_has_dim_conflicts (klass) && mono_class_is_interface (foundMethod->klass)) {
GSList* conflicts = mono_class_get_dim_conflicts (klass);
GSList* l;
MonoMethod* decl = method;

MONO_HANDLE_ARRAY_SETREF (targets, i, member);
if (decl->is_inflated)
decl = ((MonoMethodInflated*)decl)->declaring;

gboolean in_conflict = FALSE;
for (l = conflicts; l; l = l->next) {
if (decl == l->data) {
in_conflict = TRUE;
break;
}
}
if (in_conflict) {
MONO_HANDLE_ARRAY_SETREF (targets, i, NULL_HANDLE);
goto leave;
}
}

if (foundMethod->flags & METHOD_ATTRIBUTE_ABSTRACT)
MONO_HANDLE_ARRAY_SETREF (targets, i, NULL_HANDLE);
else {
MONO_HANDLE_ASSIGN (member, mono_method_get_object_handle (foundMethod, mono_class_is_interface (foundMethod->klass) ? foundMethod->klass : klass, error));
goto_if_nok (error, leave);
MONO_HANDLE_ARRAY_SETREF (targets, i, member);
}

leave:
HANDLE_FUNCTION_RETURN_VAL (is_ok (error));
Expand All @@ -2564,19 +2590,29 @@ ves_icall_RuntimeType_GetInterfaceMapData (MonoReflectionTypeHandle ref_type, Mo
if (ioffset == -1)
return;

int len = mono_class_num_methods (iclass);
MonoArrayHandle targets_arr = mono_array_new_handle (mono_defaults.method_info_class, len, error);
MonoMethod* method;
int i = 0;
gpointer iter = NULL;

while ((method = mono_class_get_methods(iclass, &iter))) {
if (method->flags & METHOD_ATTRIBUTE_VIRTUAL)
i++;
}

MonoArrayHandle targets_arr = mono_array_new_handle (mono_defaults.method_info_class, i, error);
return_if_nok (error);
MONO_HANDLE_ASSIGN (targets, targets_arr);

MonoArrayHandle methods_arr = mono_array_new_handle (mono_defaults.method_info_class, len, error);
MonoArrayHandle methods_arr = mono_array_new_handle (mono_defaults.method_info_class, i, error);
return_if_nok (error);
MONO_HANDLE_ASSIGN (methods, methods_arr);

MonoMethod* method;
int i = 0;
gpointer iter = NULL;
i = 0;
iter = NULL;

while ((method = mono_class_get_methods (iclass, &iter))) {
if (!(method->flags & METHOD_ATTRIBUTE_VIRTUAL))
continue;
if (!set_interface_map_data_method_object (method, iclass, ioffset, klass, targets, methods, i, error))
return;
i ++;
Expand Down
3 changes: 0 additions & 3 deletions src/tests/issues.targets
Original file line number Diff line number Diff line change
Expand Up @@ -1663,9 +1663,6 @@
<ExcludeList Include="$(XunitTestBinBase)/reflection/DefaultInterfaceMethods/Emit/**">
<Issue>needs triage</Issue>
</ExcludeList>
<ExcludeList Include="$(XunitTestBinBase)/reflection/DefaultInterfaceMethods/GetInterfaceMapConsumer/**">
<Issue>https://github.com/dotnet/runtime/issues/34389</Issue>
</ExcludeList>
<ExcludeList Include="$(XunitTestBinBase)/reflection/DefaultInterfaceMethods/InvokeConsumer/**">
<Issue>needs triage</Issue>
</ExcludeList>
Expand Down