[svn] r5832: nemerle/trunk/ncc: parsing/MainParser.n
testsuite/negative/gen-special-constraints.n testsuit...
malekith
svnadmin at nemerle.org
Wed Oct 19 22:11:04 CEST 2005
Log:
Allow type parameters with constraints C to be used as type parameters with constraints C. Disallow comparing null to non-reference type paremeters.
Author: malekith
Date: Wed Oct 19 22:11:02 2005
New Revision: 5832
Added:
nemerle/trunk/ncc/testsuite/negative/gen-special-constraints.n
Modified:
nemerle/trunk/ncc/parsing/MainParser.n
nemerle/trunk/ncc/testsuite/positive/gen-special.n
nemerle/trunk/ncc/typing/MType.n
nemerle/trunk/ncc/typing/StaticTyVar.n
Modified: nemerle/trunk/ncc/parsing/MainParser.n
==============================================================================
--- nemerle/trunk/ncc/parsing/MainParser.n (original)
+++ nemerle/trunk/ncc/parsing/MainParser.n Wed Oct 19 22:11:02 2005
@@ -352,7 +352,9 @@
loop ([f ()])
}
- process_groups ['a] (first : Token, name : string, f : void -> 'a) : list ['a] {
+ process_groups ['a] (first : Token, name : string, f : void -> 'a) : list ['a]
+ where 'a : class
+ {
push_stream (first);
mutable members = [];
while (stream != null) {
Added: nemerle/trunk/ncc/testsuite/negative/gen-special-constraints.n
==============================================================================
--- (empty file)
+++ nemerle/trunk/ncc/testsuite/negative/gen-special-constraints.n Wed Oct 19 22:11:02 2005
@@ -0,0 +1,15 @@
+class C [A] {
+ f : A;
+
+ foo () : void {
+ when (f != null) // E: comparing a value type A.* to .*null
+
+ {}
+ }
+
+ foo[B] (f : void -> B) : void
+ {
+ when (f () != null) // E: comparing a value type B.* to .*null
+ {}
+ }
+}
Modified: nemerle/trunk/ncc/testsuite/positive/gen-special.n
==============================================================================
--- nemerle/trunk/ncc/testsuite/positive/gen-special.n (original)
+++ nemerle/trunk/ncc/testsuite/positive/gen-special.n Wed Oct 19 22:11:02 2005
@@ -27,6 +27,21 @@
class Foo {
}
+class A' ['a] where 'a : class
+{
+ f : A ['a];
+}
+
+class B' ['a] where 'a : struct
+{
+ f : B ['a];
+}
+
+class C' ['a] where 'a : new ()
+{
+ f : C ['a];
+}
+
assert (A().foo ("a") == null);
assert (B().foo (0) == 0);
Modified: nemerle/trunk/ncc/typing/MType.n
==============================================================================
--- nemerle/trunk/ncc/typing/MType.n (original)
+++ nemerle/trunk/ncc/typing/MType.n Wed Oct 19 22:11:02 2005
@@ -436,8 +436,9 @@
| Tuple
| Void => false
- // XXX: this should be changed when we use generics
- | TyVarRef => true
+ | TyVarRef (s) =>
+ s.SpecialConstraints %&&
+ System.Reflection.GenericParameterAttributes.ReferenceTypeConstraint
| Fun
| Array
Modified: nemerle/trunk/ncc/typing/StaticTyVar.n
==============================================================================
--- nemerle/trunk/ncc/typing/StaticTyVar.n (original)
+++ nemerle/trunk/ncc/typing/StaticTyVar.n Wed Oct 19 22:11:02 2005
@@ -215,6 +215,9 @@
meth.GetHeader ().parms.IsEmpty
| _ => false
})
+ | MType.TyVarRef (s) =>
+ s.SpecialConstraints %&&
+ GenericParameterAttributes.DefaultConstructorConstraint
| _ => false
}
More information about the svn
mailing list