October 10, 2004 9:49 pm

Type parameters now have "owners"

Some people were already started wondering whether I'm still alive - I didn't blog since a month or so ....

As you can see now, I am - I was just, well, very busy with generics. Just finished a rather huge rewrite of the runtime code which is dealing with generics and I'm also preparing for my trip to Boston.

The big change is that a type parameter is now more than just a number - it also has an owner: the corresponding generic type definition or generic method. This is important if you look at the following example:

public interface IFoo<x> { } public class Test { public void Hello<t> (IFoo<t> foo) { InsertAll (foo); } public void InsertAll<u> (IFoo<u> bar) { } }

Here, foo and bar have two different types: IFoo<T> and IFoo<U>. The old runtime could not distinguish them since the internal representation of T and U was just a number: they were both the first method type parameter in some generic method.

This required some larger changes in all code which was parsing the metadata since a type parameter is indeed just a number in the metadata. However, I solved this problem by passing a MonoGenericContainer (pointing to the current generic type / method) to all methods which are parsing metadata.

Posted by martin at October 10, 2004 9:49 pm.