Skip to content

Commit

Permalink
2008-04-28 Mark Probst <mark.probst@gmail.com>
Browse files Browse the repository at this point in the history
	* 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
schani committed Apr 28, 2008
1 parent 572fcc5 commit 1e72fad
Show file tree
Hide file tree
Showing 5 changed files with 52 additions and 15 deletions.
5 changes: 5 additions & 0 deletions mono/metadata/ChangeLog
Original file line number Diff line number Diff line change
@@ -1,3 +1,8 @@
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.
Expand Down
35 changes: 21 additions & 14 deletions mono/metadata/generic-sharing.c
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
6 changes: 6 additions & 0 deletions mono/tests/ChangeLog
Original file line number Diff line number Diff line change
@@ -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
Expand Down
4 changes: 3 additions & 1 deletion mono/tests/Makefile.am
Original file line number Diff line number Diff line change
Expand Up @@ -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 \
Expand Down Expand Up @@ -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
Expand All @@ -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
Expand Down
17 changes: 17 additions & 0 deletions mono/tests/generic-array-type.2.cs
Original file line number Diff line number Diff line change
@@ -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;
}
}

0 comments on commit 1e72fad

Please sign in to comment.