[nem-en] Some problems with typeof operator (when applied to a tuple type)

Michal Moskal michal.moskal at gmail.com
Wed Feb 14 19:59:06 CET 2007


On 2/14/07, Vladimir Reshetnikov <v.reshetnikov at gmail.com> wrote:
> [nemerle]
> using System.Console;
>
> class A[T,S] { }
>
> WriteLine(typeof(A[_,_]).IsGenericTypeDefinition); // True
> WriteLine(typeof(A[_,_]).Equals(typeof(A[object,object]))); // False
>
> WriteLine(typeof(_ * _).IsGenericTypeDefinition); // False
> WriteLine(typeof(_ * _).Equals(typeof(object * object))); // True
> [/nemerle]
>
> Obviously, that (_ * _) is treated as closed constructed polymorphic
> type (object * object), not as unbounded polymorpic type (_ * _), that
> is Nemerle.Builtins.Tuple[_,_].
> IMO, this is an error.

This is because _ is treated as "fresh type variable" in most type
contexts, so I think this is some kind of special case for typeof.


-- 
   Michał


More information about the devel-en mailing list