Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

2008-04-28 Mark Probst <mark.probst@gmail.com>

	* generic-sharing.c: Search for type arguments in array element
	types as well.

2008-04-28  Mark Probst  <mark.probst@gmail.com>

	* generic-array-type.2.cs: Test case for type arguments in arrays.

	* Makefile.am: Added test.

svn path=/trunk/mono/; revision=102047
  • Loading branch information...
commit 1e72fad17cbb45a70aace696298a106d32642da8 1 parent 572fcc5
@schani schani authored
View
5 mono/metadata/ChangeLog
@@ -1,5 +1,10 @@
2008-04-28 Mark Probst <mark.probst@gmail.com>
+ * generic-sharing.c: Search for type arguments in array element
+ types as well.
+
+2008-04-28 Mark Probst <mark.probst@gmail.com>
+
* class-internals.h, generic-sharing.c: New, small runtime generic context.
* metadata-internals.h, domain.c, image.c: Less bookkeeping is required for the new RGCTX.
View
35 mono/metadata/generic-sharing.c
@@ -24,25 +24,32 @@
static int
type_check_context_used (MonoType *type, gboolean recursive)
{
- int t = mono_type_get_type (type);
- int context_used = 0;
-
- if (t == MONO_TYPE_VAR)
- context_used |= MONO_GENERIC_CONTEXT_USED_CLASS;
- else if (t == MONO_TYPE_MVAR)
- context_used |= MONO_GENERIC_CONTEXT_USED_METHOD;
- else if (recursive) {
- if (t == MONO_TYPE_CLASS)
- context_used |= mono_class_check_context_used (mono_type_get_class (type));
- else if (t == MONO_TYPE_GENERICINST) {
+ switch (mono_type_get_type (type)) {
+ case MONO_TYPE_VAR:
+ return MONO_GENERIC_CONTEXT_USED_CLASS;
+ case MONO_TYPE_MVAR:
+ return MONO_GENERIC_CONTEXT_USED_METHOD;
+ case MONO_TYPE_SZARRAY:
+ return mono_class_check_context_used (mono_type_get_class (type));
+ case MONO_TYPE_ARRAY:
+ return mono_class_check_context_used (mono_type_get_array_type (type)->eklass);
+ case MONO_TYPE_CLASS:
+ if (recursive)
+ return mono_class_check_context_used (mono_type_get_class (type));
+ else
+ return 0;
+ case MONO_TYPE_GENERICINST:
+ if (recursive) {
MonoGenericClass *gclass = type->data.generic_class;
- context_used |= mono_generic_context_check_used (&gclass->context);
g_assert (gclass->container_class->generic_container);
+ return mono_generic_context_check_used (&gclass->context);
+ } else {
+ return 0;
}
+ default:
+ return 0;
}
-
- return context_used;
}
static int
View
6 mono/tests/ChangeLog
@@ -1,3 +1,9 @@
+2008-04-28 Mark Probst <mark.probst@gmail.com>
+
+ * generic-array-type.2.cs: Test case for type arguments in arrays.
+
+ * Makefile.am: Added test.
+
2008-04-25 Mark Probst <mark.probst@gmail.com>
* generic-interface-methods.2.cs: Test case for generic interface
View
4 mono/tests/Makefile.am
@@ -261,6 +261,7 @@ BASE_TEST_CS_SRC= \
generic-sizeof.2.cs \
generic-virtual.2.cs \
generic-interface-methods.2.cs \
+ generic-array-type.2.cs \
recursive-generics.2.cs \
bug-80392.2.cs \
dynamic-method-access.2.cs \
@@ -673,7 +674,7 @@ test-generic-sharing : generics-sharing.2.exe shared-generic-methods.2.exe \
generic-ldtoken.2.exe \
generic-ldtoken-method.2.exe generic-ldtoken-field.2.exe \
generic-virtual.2.exe generic-tailcall.2.exe \
- generic-interface-methods.2.exe
+ generic-interface-methods.2.exe generic-array-type.2.exe
$(RUNTIME) -O=gshared,-inline generics-sharing.2.exe
$(RUNTIME) -O=gshared,-inline shared-generic-methods.2.exe
$(RUNTIME) -O=gshared,-inline shared-generic-synchronized.2.exe
@@ -691,6 +692,7 @@ test-generic-sharing : generics-sharing.2.exe shared-generic-methods.2.exe \
$(RUNTIME) -O=gshared,-inline generic-virtual.2.exe
$(RUNTIME) -O=gshared,-inline generic-tailcall.2.exe
$(RUNTIME) -O=gshared,-inline generic-interface-methods.2.exe
+ $(RUNTIME) -O=gshared,-inline generic-array-type.2.exe
EXTRA_DIST += async-exceptions.cs
async-exceptions.exe : async-exceptions.cs
View
17 mono/tests/generic-array-type.2.cs
@@ -0,0 +1,17 @@
+using System;
+
+public class Gen<T> {
+ public Type arrayType () {
+ return typeof (T []);
+ }
+}
+
+public class main {
+ public static int Main () {
+ Gen<string> gs = new Gen<string> ();
+
+ if (gs.arrayType () != typeof (string []))
+ return 1;
+ return 0;
+ }
+}
Please sign in to comment.
Something went wrong with that request. Please try again.