From: Zoltan Varga Date: Tue, 6 Oct 2009 17:07:40 +0000 (-0000) Subject: 2009-10-06 Zoltan Varga X-Git-Url: http://wien.tomnetworks.com/gitweb/?a=commitdiff_plain;h=084a1cf1e35372ae488802a9abce5cd86af5b21e;p=mono.git 2009-10-06 Zoltan Varga * aot-compiler.c (add_generic_class): Add an instance of GenericComparer for each instance of Comparer. * generics.cs: Add a new test. svn path=/trunk/mono/; revision=143531 --- diff --git a/mono/mini/ChangeLog b/mono/mini/ChangeLog index 27d8a4aa8f6..3c774a321c3 100644 --- a/mono/mini/ChangeLog +++ b/mono/mini/ChangeLog @@ -1,3 +1,10 @@ +2009-10-06 Zoltan Varga + + * aot-compiler.c (add_generic_class): Add an instance of GenericComparer for + each instance of Comparer. + + * generics.cs: Add a new test. + 2009-10-04 Zoltan Varga * aot-compiler.c (add_generic_class): Only add GetGenericValueImpl wrappers diff --git a/mono/mini/aot-compiler.c b/mono/mini/aot-compiler.c index fb62baaf487..f6ce0fcfe05 100644 --- a/mono/mini/aot-compiler.c +++ b/mono/mini/aot-compiler.c @@ -2150,7 +2150,27 @@ add_generic_class (MonoAotCompile *acfg, MonoClass *klass) add_extra_method (acfg, mono_marshal_get_native_wrapper (mono_class_inflate_generic_method (get_method, &ctx), TRUE, TRUE)); } } + } + + /* Add an instance of GenericComparer which is created dynamically by Comparer */ + if (klass->image == mono_defaults.corlib && !strcmp (klass->name_space, "System.Collections.Generic") && !strcmp (klass->name, "Comparer`1")) { + MonoClass *tclass = mono_class_from_mono_type (klass->generic_class->context.class_inst->type_argv [0]); + MonoClass *icomparable, *gcomparer; + MonoGenericContext ctx; + MonoType *args [16]; + memset (&ctx, 0, sizeof (ctx)); + + icomparable = mono_class_from_name (mono_defaults.corlib, "System", "IComparable`1"); + g_assert (icomparable); + args [0] = &tclass->byval_arg; + ctx.class_inst = mono_metadata_get_generic_inst (1, args); + + if (mono_class_is_assignable_from (mono_class_inflate_generic_class (icomparable, &ctx), tclass)) { + gcomparer = mono_class_from_name (mono_defaults.corlib, "System.Collections.Generic", "GenericComparer`1"); + g_assert (gcomparer); + add_generic_class (acfg, mono_class_inflate_generic_class (gcomparer, &ctx)); + } } } diff --git a/mono/mini/generics.cs b/mono/mini/generics.cs index 3a735ef23bd..15fc3afc63f 100644 --- a/mono/mini/generics.cs +++ b/mono/mini/generics.cs @@ -457,6 +457,11 @@ class Tests { return filteredWords.Count (); } + public static int test_0_fullaot_comparer_t () { + var l = new SortedList (); + return l.Count; + } + static int cctor_count = 0; public abstract class Beta