From 1615325af7691d9d1c4d2f7fe5da2e3959784e44 Mon Sep 17 00:00:00 2001 From: kumpera Date: Wed, 16 Dec 2009 19:41:24 +0000 Subject: [PATCH] 2009-12-16 Rodrigo Kumpera * reflection.c (mono_type_get_object): If the type is VAR or MVAR check if the owner class has not been finished before returning reflection_info. Fixes #565127. git-svn-id: svn+ssh://mono-cvs.ximian.com/source/trunk/mono@148575 e3ebcda4-bce8-0310-ba0a-eca2169e7518 --- mono/metadata/ChangeLog | 7 +++++++ mono/metadata/reflection.c | 21 ++++++++++++++++++++- 2 files changed, 27 insertions(+), 1 deletion(-) diff --git a/mono/metadata/ChangeLog b/mono/metadata/ChangeLog index 66c38c602..be3299f53 100644 --- a/mono/metadata/ChangeLog +++ b/mono/metadata/ChangeLog @@ -1,3 +1,10 @@ +2009-12-16 Rodrigo Kumpera + + * reflection.c (mono_type_get_object): If the type is VAR or MVAR check + if the owner class has not been finished before returning reflection_info. + + Fixes #565127. + 2009-12-16 Zoltan Varga * reflection.c (mono_custom_attrs_from_param): Avoid a crash if a dynamic diff --git a/mono/metadata/reflection.c b/mono/metadata/reflection.c index c9113e7c5..f94fdab5b 100644 --- a/mono/metadata/reflection.c +++ b/mono/metadata/reflection.c @@ -6377,9 +6377,28 @@ mono_type_get_object (MonoDomain *domain, MonoType *type) } if (klass->reflection_info && !klass->wastypebuilder) { + gboolean is_type_done = TRUE; + /* Generic parameters have reflection_info set but they are not finished together with their enclosing type. + * We must ensure that once a type is finished we don't return a GenericTypeParameterBuilder. + * We can't simply close the types as this will interfere with other parts of the generics machinery. + */ + if (klass->byval_arg.type == MONO_TYPE_MVAR || klass->byval_arg.type == MONO_TYPE_VAR) { + MonoGenericParam *gparam = klass->byval_arg.data.generic_param; + + if (gparam->owner && gparam->owner->is_method) { + MonoMethod *method = gparam->owner->owner.method; + if (mono_class_get_generic_type_definition (method->klass)->wastypebuilder) + is_type_done = FALSE; + } else if (gparam->owner && !gparam->owner->is_method) { + MonoClass *klass = gparam->owner->owner.klass; + if (mono_class_get_generic_type_definition (klass)->wastypebuilder) + is_type_done = FALSE; + } + } + /* g_assert_not_reached (); */ /* should this be considered an error condition? */ - if (!type->byref) { + if (is_type_done && !type->byref) { mono_domain_unlock (domain); mono_loader_unlock (); return klass->reflection_info; -- 2.11.4.GIT