[svn] r6516: nemerle/trunk/ncc: generation/Typer4.n
hierarchy/CustomAttribute.n testsuite/positive/typeof....
nazgul
svnadmin at nemerle.org
Sun Aug 13 01:23:58 CEST 2006
Log:
Allow specifying open generic types in typeof expressions
Author: nazgul
Date: Sun Aug 13 01:23:53 2006
New Revision: 6516
Modified:
nemerle/trunk/ncc/generation/Typer4.n
nemerle/trunk/ncc/hierarchy/CustomAttribute.n
nemerle/trunk/ncc/testsuite/positive/typeof.n
nemerle/trunk/ncc/typing/Typer.n
Modified: nemerle/trunk/ncc/generation/Typer4.n
==============================================================================
--- nemerle/trunk/ncc/generation/Typer4.n (original)
+++ nemerle/trunk/ncc/generation/Typer4.n Sun Aug 13 01:23:53 2006
@@ -426,12 +426,7 @@
#endif
false
- | TypeOf (_t) =>
- #if CHECK_STV
- CheckSTV (_t);
- #endif
- false
-
+ | TypeOf
| StaticRef
| LocalRef
| ImplicitValueTypeCtor
Modified: nemerle/trunk/ncc/hierarchy/CustomAttribute.n
==============================================================================
--- nemerle/trunk/ncc/hierarchy/CustomAttribute.n (original)
+++ nemerle/trunk/ncc/hierarchy/CustomAttribute.n Sun Aug 13 01:23:53 2006
@@ -64,7 +64,15 @@
| <[ typeof ($t) ]> when ti != null =>
match (ti.BindType (t)) {
- | MType.Class (tc, []) => (tc.SystemType, InternalType.Type)
+ | MType.Class (tc, args) =>
+ def is_free (a) { !(a is MType) }
+ if (args.Exists (is_free)) {
+ when (!args.ForAll (is_free))
+ Message.Error ("to create open generic type all arguments must be open `_'");
+ (tc.SystemType, InternalType.Type)
+ }
+ else
+ (tc.SystemType, InternalType.Type)
| _ =>
Message.FatalError ($"invalid / unbound type `$(t)' in attribute parameter")
}
Modified: nemerle/trunk/ncc/testsuite/positive/typeof.n
==============================================================================
--- nemerle/trunk/ncc/testsuite/positive/typeof.n (original)
+++ nemerle/trunk/ncc/testsuite/positive/typeof.n Sun Aug 13 01:23:53 2006
@@ -1,4 +1,25 @@
+using System.Diagnostics;
+
+// Try get open generic type!
+[DebuggerTypeProxy(typeof(TestProxy[_]))]
+public class Test[T]
+{
+ public this(val : T) { _val = val; }
+ public _val : T;
+}
+
+public class TestProxy[T]
+{
+ public this(test : Test[T]) { _test = test; }
+
+ mutable _test : Test[T];
+
+ public Val : T { get { _test._val; } }
+}
+
+
[Record]
+[DebuggerTypeProxy(typeof(System.Collections.Generic.List[int]))]
class X {
val : int;
@@ -46,6 +67,10 @@
assert (!(x1 : object).Equals (x3));
Nemerle.IO.print (Y (39).SomeMeth (42, "42") + "\n");
+
+ System.Console.WriteLine (typeof (System.Collections.Generic.List[_]));
+ System.Console.WriteLine (typeof (System.Collections.Generic.Dictionary[_,_]));
+ System.Console.WriteLine (typeof (System.Collections.Generic.List[int]));
}
}
@@ -53,5 +78,8 @@
BEGIN-OUTPUT
System.String, System.Int32
42 42 42
+System.Collections.Generic.List`1[T]
+System.Collections.Generic.Dictionary`2[TKey,TValue]
+System.Collections.Generic.List`1[System.Int32]
END-OUTPUT
*/
Modified: nemerle/trunk/ncc/typing/Typer.n
==============================================================================
--- nemerle/trunk/ncc/typing/Typer.n (original)
+++ nemerle/trunk/ncc/typing/Typer.n Sun Aug 13 01:23:53 2006
@@ -1308,8 +1308,18 @@
| PT.PExpr.Typeof (t) =>
_ = Expect (expected, InternalType.Type, "typeof result");
- TExpr.TypeOf (BindType (t))
-
+ def ty = BindType (t);
+ match (ty) {
+ | MType.Class (tc, args) =>
+ def is_free (a) { !(a is MType) }
+ if (args.Exists (is_free)) {
+ when (!args.ForAll (is_free))
+ Message.Error ("to create open generic type, all arguments must be open `_'");
+ TExpr.TypeOf (tc.GetMemType())
+ }
+ else TExpr.TypeOf (ty)
+ | _ => TExpr.TypeOf (ty)
+ }
| PT.PExpr.TypeConversion (e, t) =>
def t = BindType (t).Fix ();
More information about the svn
mailing list