@@ -932,7 +932,8 @@ mono_class_setup_vtable_full (MonoClass *klass, GList *in_setup)
932
932
context = mono_class_get_context (klass );
933
933
type_token = mono_class_get_generic_class (klass )-> container_class -> type_token ;
934
934
} else {
935
- context = (MonoGenericContext * ) mono_class_try_get_generic_container (klass ); //FIXME is this a case of a try?
935
+ MonoGenericContainer * container = mono_class_try_get_generic_container (klass ); //FIXME is this a case of a try?
936
+ context = container ? & container -> context : NULL ;
936
937
type_token = klass -> type_token ;
937
938
}
938
939
@@ -1010,30 +1011,14 @@ apply_override (MonoClass *klass, MonoClass *override_class, MonoMethod **vtable
1010
1011
MonoMethod * prev_override = (MonoMethod * )g_hash_table_lookup (map , decl );
1011
1012
MonoClass * prev_override_class = (MonoClass * )g_hash_table_lookup (class_map , decl );
1012
1013
1014
+ g_assert (override_class == override -> klass );
1015
+
1013
1016
g_hash_table_insert (map , decl , override );
1014
1017
g_hash_table_insert (class_map , decl , override_class );
1015
1018
1016
1019
/* Collect potentially conflicting overrides which are introduced by default interface methods */
1017
1020
if (prev_override ) {
1018
- ERROR_DECL (error );
1019
-
1020
- /*
1021
- * The override methods are part of the generic definition, need to inflate them so their
1022
- * parent class becomes the actual interface/class containing the override, i.e.
1023
- * IFace<T> in:
1024
- * class Foo<T> : IFace<T>
1025
- * This is needed so the mono_class_is_assignable_from_internal () calls in the
1026
- * conflict resolution work.
1027
- */
1028
- if (mono_class_is_ginst (override_class )) {
1029
- override = mono_class_inflate_generic_method_checked (override , & mono_class_get_generic_class (override_class )-> context , error );
1030
- mono_error_assert_ok (error );
1031
- }
1032
-
1033
- if (mono_class_is_ginst (prev_override_class )) {
1034
- prev_override = mono_class_inflate_generic_method_checked (prev_override , & mono_class_get_generic_class (prev_override_class )-> context , error );
1035
- mono_error_assert_ok (error );
1036
- }
1021
+ g_assert (prev_override -> klass == prev_override_class );
1037
1022
1038
1023
if (!* conflict_map )
1039
1024
* conflict_map = g_hash_table_new (mono_aligned_addr_hash , NULL );
@@ -1771,10 +1756,9 @@ mono_class_setup_vtable_general (MonoClass *klass, MonoMethod **overrides, int o
1771
1756
MonoMethod * override = iface_overrides [i * 2 + 1 ];
1772
1757
if (mono_class_is_gtd (override -> klass )) {
1773
1758
override = mono_class_inflate_generic_method_full_checked (override , ic , mono_class_get_context (ic ), error );
1774
- } else if (decl -> is_inflated ) {
1775
- override = mono_class_inflate_generic_method_checked (override , mono_method_get_context (decl ), error );
1776
- mono_error_assert_ok (error );
1777
- }
1759
+ }
1760
+ // there used to be code here to inflate decl if decl->is_inflated, but in https://github.com/dotnet/runtime/pull/64102#discussion_r790019545 we
1761
+ // think that this does not correspond to any real code.
1778
1762
if (!apply_override (klass , ic , vtable , decl , override , & override_map , & override_class_map , & conflict_map ))
1779
1763
goto fail ;
1780
1764
}
@@ -1786,6 +1770,18 @@ mono_class_setup_vtable_general (MonoClass *klass, MonoMethod **overrides, int o
1786
1770
MonoMethod * decl = overrides [i * 2 ];
1787
1771
MonoMethod * override = overrides [i * 2 + 1 ];
1788
1772
if (MONO_CLASS_IS_INTERFACE_INTERNAL (decl -> klass )) {
1773
+ /*
1774
+ * We expect override methods that are part of a generic definition, to have
1775
+ * their parent class be the actual interface/class containing the override,
1776
+ * i.e.
1777
+ *
1778
+ * IFace<T> in:
1779
+ * class Foo<T> : IFace<T>
1780
+ *
1781
+ * This is needed so the mono_class_is_assignable_from_internal () calls in the
1782
+ * conflict resolution work.
1783
+ */
1784
+ g_assert (override -> klass == klass );
1789
1785
if (!apply_override (klass , klass , vtable , decl , override , & override_map , & override_class_map , & conflict_map ))
1790
1786
goto fail ;
1791
1787
}
0 commit comments