Skip to content

Commit 3768e58

Browse files
Remove Assert in Method.MakeGeneric on Invalid Arg
The call to mono_class_inflate_generic_method_checked will set error when there are invalid types (e.g. typeof(void)/typeof(int*)) passed in. This should not be an assert, it should fall to the "Invalid generic arguments" message below. This does lose the error returned by mono_class_inflate_generic_method_checked but that error isn't user friendly. It would report be something like: "MVAR 1 cannot be expanded with type 0x1" Instead report the more readable error to the user. Fix: 71339
1 parent 64e178b commit 3768e58

3 files changed

Lines changed: 3 additions & 2 deletions

File tree

src/mono/mono/metadata/reflection.c

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2728,9 +2728,8 @@ reflection_bind_generic_method_parameters (MonoMethod *method, MonoArrayHandle t
27282728
tmp_context.method_inst = ginst;
27292729

27302730
inflated = mono_class_inflate_generic_method_checked (method, &tmp_context, error);
2731-
mono_error_assert_ok (error);
27322731

2733-
if (!mono_verifier_is_method_valid_generic_instantiation (inflated)) {
2732+
if (!is_ok(error) || !inflated || !mono_verifier_is_method_valid_generic_instantiation (inflated)) {
27342733
mono_error_set_argument (error, NULL, "Invalid generic arguments");
27352734
return NULL;
27362735
}
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
{"requests":[{"kind":"cache","version":2},{"kind":"cmakeFiles","version":1},{"kind":"codemodel","version":2},{"kind":"toolchains","version":1}]}
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
msvc_x64_x64

0 commit comments

Comments
 (0)